python modis hdfファイルを読み込む
from pyhdf.SD import SD, SDC
import pprint
HDF_FILR_URL = "E:\MyDownloads\MOD021KM.A2012156.0115.006.2014225090534.hdf"
file = SD(HDF_FILR_URL)
print(file.info())
出力(31,58)は、31の科学データセットがあることを示している.
datasets_dic = file.datasets()
for idx,sds in enumerate(datasets_dic.keys()):
print(idx,sds)
出力データセット番号名0 Latitude
1 Longitude
2 EV_1KM_RefSB
3 EV_1KM_RefSB_Uncert_Indexes
4 EV_1KM_Emissive
5 EV_1KM_Emissive_Uncert_Indexes
6 EV_250_Aggr1km_RefSB
7 EV_250_Aggr1km_RefSB_Uncert_Indexes
8 EV_250_Aggr1km_RefSB_Samples_Used
9 EV_500_Aggr1km_RefSB
10 EV_500_Aggr1km_RefSB_Uncert_Indexes
11 EV_500_Aggr1km_RefSB_Samples_Used
12 Height
13 SensorZenith
14 SensorAzimuth
15 Range
16 SolarZenith
17 SolarAzimuth
18 gflags
19 EV_Band26
20 EV_Band26_Uncert_Indexes
21 Band_250M
22 Band_500M
23 Band_1KM_RefSB
24 Band_1KM_Emissive
25 Noise in Thermal Detectors
26 Change in relative responses of thermal detectors
27 DC Restore Change for Thermal Bands
28 DC Restore Change for Reflective 250m Bands
29 DC Restore Change for Reflective 500m Bands
30 DC Restore Change for Reflective 1km Bands
sds_obj = file.select('Latitude') # select sds
sds_obj = file.select('cloud_top_temperature_1km') # select sds
data = sds_obj.get() # get sds data
print data
出力cloud_top_temperature_1 kmデータ[[19875 19720 19740 ..., 19608 19591 19533]
[19473 19413 19272 ..., 19431 19422 19420]
[19125 19335 18972 ..., 19344 19475 19347]
...,
[18335 18240 18584 ..., 12935 12819 12955]
[18437 18747 18843 ..., 13152 13085 12855]
[18662 18858 18584 ..., 13241 12866 12797]]
[[23891 24528 24340 ..., 23878 23999 24114]
[23780 23818 24004 ..., 23648 23735 23648]
[23934 24230 23675 ..., 23861 23544 23839]
...,
[22585 22190 22585 ..., 18565 18332 18656]
[22169 22499 22573 ..., 18441 18818 18247]
[22313 22571 22719 ..., 18555 18521 18443]]]
pprint.pprint(sds_obj.attributes())
しゅつりょくデータとくせい
{'_FillValue': 65535, 'band_names': '20,21,22,23,24,25,27,28,29,30,31,32,33,34,35,36', 'long_name': 'Earth View 1KM Emissive Bands Scaled Integers', 'radiance_offsets': [2730.58349609375, 2730.58349609375, 2730.58349609375, 2730.58349609375, 1077.44482421875, 1560.3333740234375, 2730.583251953125, 2317.48828125, 2730.58349609375, 1560.333251953125, 1577.3397216796875, 1658.2213134765625, 2501.297607421875, 2501.297607421875, 2501.2978515625, 2501.2978515625], 'radiance_scales': [6.262398528633639e-05, 0.0031495101284235716, 6.921597378095612e-05, 7.910397835075855e-05, 3.155614103889093e-05, 5.639820665237494e-05, 0.00011755729792639613, 0.0001924497337313369, 0.000532486941665411, 0.0004063234373461455, 0.0008400219958275557, 0.000729697581846267, 0.00026226387126371264, 0.00020069582387804985, 0.0001767082721926272, 0.0001183385684271343], 'radiance_units': 'Watts/m^2/micrometer/steradian', 'units': 'none', 'valid_range': [0, 32767]}