- 积分
- 346
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2013-4-6
- 最后登录
- 1970-1-1
|
发表于 2018-1-31 16:45:34
|
显示全部楼层
PRO GRIB_Read_ncep, HEADER=header
path='K:\ncep\'
outpath='K:\ncep\IDL_result\'
files=findfile(path+'*fnl*.grib2')
file=filepath('fnl_20170831_18_00.grib2')
n=n_elements(file)
compile_opt idl2
filename = DIALOG_PICKFILE(title ='fnl_20170831_18_00.grib2')
;��grib�ļ����ָ��
f = GRIB_OPEN(filename)
;�������ָ��
data = PTRARR(GRIB_COUNT(filename))
;���������header�����ʼ������
IF(ARG_PRESENT(header)) THEN header = MAKE_ARRAY(GRIB_COUNT(filename), /OBJ)
;��grib�ļ��л�ȡgrib���
h = GRIB_NEW_FROM_FILE(f)
;��ʼ���������
i=0
;ѭ����ȡ
WHILE(h NE !NULL) DO BEGIN
;��ȡֵ����
values = GRIB_GET_VALUES(h)
data = PTR_NEW(values)
;����Ҫ��ȡheader�����ζ�ȡ
IF (ARG_PRESENT(header)) THEN BEGIN
kiter = GRIB_KEYS_ITERATOR_NEW(h, /COMPUTED)
header = LIST()
res = GRIB_KEYS_ITERATOR_NEXT(kiter)
WHILE (res EQ 1) DO BEGIN
key = GRIB_KEYS_ITERATOR_GET_NAME(kiter)
IF (STRCMP(key, 'values', /FOLD_CASE) EQ 0) THEN BEGIN
IF (GRIB_GET_SIZE(h, key) GT 1) THEN $
val = GRIB_GET_ARRAY(h, key)ELSE val = GRIB_GET(h, key)
IF (STRCMP(key, '7777', /FOLD_CASE) EQ 1) THEN key = 'end_section'
key_value = CREATE_STRUCT(key, val)
header.ADD, key_value
ENDIF
res = GRIB_KEYS_ITERATOR_NEXT(kiter)
ENDWHILE
GRIB_KEYS_ITERATOR_DELETE, kiter
ENDIF
GRIB_RELEASE, h
h = GRIB_NEW_FROM_FILE(f)
i++
ENDWHILE
;�ر�Grib�ļ�ָ��
GRIB_CLOSE, f
;�鿴��ȡ�������Ϣ
HELP, data,/str
END
我用这样的程序运行时,只能得到DATA POINTER = Array[353]
file=filepath('fnl_20170831_18_00.grib2',$
SUBDIRECTORY=['examples','data'])
GRIB_LIST, file
我用这个时,得到:DATA POINTER = Array[353]
1 unknown DOUBLEARRAY[65160]
2 unknown DOUBLEARRAY[65160]
3 unknown DOUBLEARRAY[65160]
4 unknown DOUBLEARRAY[65160]
5 unknown DOUBLEARRAY[65160]
6 unknown DOUBLEARRAY[65160]
7 unknown DOUBLEARRAY[65160]
8 unknown DOUBLEARRAY[65160]
9 unknown DOUBLEARRAY[65160]
10 unknown DOUBLEARRAY[65160]
11 unknown DOUBLEARRAY[65160]
12 unknown DOUBLEARRAY[65160]。。。
全是不知道名字的。。。。
file=filepath('fnl_20170831_18_00.grib2',$
SUBDIRECTORY=['examples','data'])
GRIB_LIST, file,1
用这个时,得到的是:
parametersVersion 1
2 thousand 1000
2 hundred LONGARRAY[2]
2 globalDomain 'g'
2 GRIBEditionNumber 2
2 grib2divider 1000000
2 missingValue 9999
2 ieeeFloats 1
2 section0Length 16
2 identifier 'GRIB'
2 discipline 0
2 editionNumber 2
2 totalLength 52455
2 sectionNumber LONGARRAY[7]
2 section1Length 21
2 numberOfSection LONGARRAY[6]
2 centre 'kwbc'
2 centreDescription 'US National Weather Service - NCEP '
2 subCentre 0
2 tablesVersion 2
2 masterDir 'grib2/tables/[tablesVersion]'
2 localTablesVersion 1
2 localDir ''
2 significanceOfReferenceTime 1
2 year 2017
2 month 8
2 day 31
2 hour 18
2 minute 0
2 second 0
2 dataDate 20170831
2 julianDay 2457997.3
2 dataTime 1800
2 productionStatusOfProcessedData 0
2 typeOfProcessedData '1'
2 md5Section1 BYTEARRAY[16]
2 selectStepTemplateInterval 1
2 selectStepTemplateInstant 1
2 stepType 'instant'
2 sectionNumber LONGARRAY[7]
2 grib2LocalSectionPresent 0
2 sectionNumber LONGARRAY[7]
2 gridDescriptionSectionPresent 1
2 section3Length 72
2 numberOfSection LONGARRAY[6]
2 sourceOfGridDefinition 0
2 numberOfDataPoints 65160
2 numberOfOctectsForNumberOfPoints 0
2 interpretationOfNumberOfPoints 0
2 PLPresent 0
2 gridDefinitionTemplateNumber 0
2 shapeOfTheEarth 6
2 scaleFactorOfRadiusOfSphericalEarth 0
2 scaledValueOfRadiusOfSphericalEarth 0
2 scaleFactorOfEarthMajorAxis 0
2 scaledValueOfEarthMajorAxis 0
2 scaleFactorOfEarthMinorAxis 0
2 scaledValueOfEarthMinorAxis 0
2 radius 6371229
2 Ni 360
2 Nj 181
2 basicAngleOfTheInitialProductionDomain 0
2 mBasicAngle 0
2 angleMultiplier 1
2 mAngleMultiplier 1000000
2 subdivisionsOfBasicAngle -1
2 angleDivisor 1000000
2 latitudeOfFirstGridPoint 90000000
2 longitudeOfFirstGridPoint 0
2 resolutionAndComponentFlags 48
2 resolutionAndComponentFlags1 0
2 resolutionAndComponentFlags2 0
2 iDirectionIncrementGiven 1
2 jDirectionIncrementGiven 1
2 uvRelativeToGrid 0
2 resolutionAndComponentFlags6 0
2 resolutionAndComponentFlags7 0
2 resolutionAndComponentFlags8 0
2 ijDirectionIncrementGiven '1'
2 latitudeOfLastGridPoint -90000000
2 longitudeOfLastGridPoint 359000000
2 iDirectionIncrement 1000000
2 jDirectionIncrement 1000000
2 scanningMode 0
2 iScansNegatively 0
2 jScansPositively 0
2 jPointsAreConsecutive 0
2 alternativeRowScanning 0
2 iScansPositively 1
2 scanningMode5 0
2 scanningMode6 0
2 scanningMode7 0
2 scanningMode8 0
2 g2grid DOUBLEARRAY[6]
2 latitudeOfFirstGridPointInDegrees 90.000000
2 longitudeOfFirstGridPointInDegrees 0.00000000
2 latitudeOfLastGridPointInDegrees -90.000000
2 longitudeOfLastGridPointInDegrees 359.00000
2 iDirectionIncrementInDegrees 1.0000000
2 jDirectionIncrementInDegrees 1.0000000
2 latLonValues DOUBLEARRAY[195480]
2 latitudes DOUBLEARRAY[65160]
2 longitudes DOUBLEARRAY[65160]
2 distinctLatitudes DOUBLEARRAY[181]
2 distinctLongitudes DOUBLEARRAY[360]
2 section3Padding 50
2 gridType 'regular_ll'
2 md5Section3 BYTEARRAY[16]
2 sectionNumber LONGARRAY[7]
2 section4Length 34
2 numberOfSection LONGARRAY[6]
2 NV 0
2 neitherPresent 0
2 productDefinitionTemplateNumber 0
2 Parameter information
2 parameterCategory 2
2 parameterNumber 3
2 parameterUnits '3'
2 parameterName '3'
2 typeOfGeneratingProcess 2
2 backgroundProcess 0
2 generatingProcessIdentifier 81
2 hoursAfterDataCutoff 0
2 minutesAfterDataCutoff 0
2 indicatorOfUnitOfTimeRange 1
2 stepUnits 1
2 forecastTime 0
2 startStep 0
2 endStep 0
2 stepRange '0'
2 stepTypeInternal 'instant'
2 validityDate 20170831
2 validityTime 1800
2 typeOfFirstFixedSurface '220'
2 unitsOfFirstFixedSurface '220'
2 nameOfFirstFixedSurface '220'
2 scaleFactorOfFirstFixedSurface 0
2 scaledValueOfFirstFixedSurface 0
2 typeOfSecondFixedSurface 255
2 unitsOfSecondFixedSurface 'unknown'
2 nameOfSecondFixedSurface 'Missing'
2 scaleFactorOfSecondFixedSurface 0
2 scaledValueOfSecondFixedSurface 0
2 pressureUnits 'hPa'
2 typeOfLevel 'unknown'
2 level 0
2 bottomLevel 0
2 topLevel 0
2 paramIdECMF 0
2 paramId 0
2 shortNameECMF 'unknown'
2 shortName 'unknown'
2 unitsECMF 'unknown'
2 units 'unknown'
2 nameECMF 'unknown'
2 name 'unknown'
2 cfNameECMF 'unknown'
2 cfName 'unknown'
2 ifsParam 0
2 genVertHeightCoords 0
2 PVPresent 0
2 md5Section4 BYTEARRAY[16]
2 sectionNumber LONGARRAY[7]
2 grib 2 Section 5 DATA REPRESENTATION SECTION
2 section5Length 49
2 numberOfSection LONGARRAY[6]
2 numberOfValues 65160
2 dataRepresentationTemplateNumber 3
2 packingType 'grid_complex_spatial_differencing'
2 referenceValue -453.75006
2 referenceValueError 3.0517578e-005
2 binaryScaleFactor 0
2 decimalScaleFactor 1
2 bitsPerValue 11
2 typeOfOriginalFieldValues 0
2 groupSplittingMethodUsed 1
2 missingValueManagementUsed 0
2 primaryMissingValueSubstitute 1649987994
2 secondaryMissingValueSubstitute -1
2 numberOfGroupsOfDataValues 2330
2 referenceForGroupWidths 0
2 numberOfBitsUsedForTheGroupWidths 4
2 referenceForGroupLengths 1
2 lengthIncrementForTheGroupLengths 1
2 trueLengthOfLastGroup 29
2 numberOfBitsForScaledGroupLengths 7
2 orderOfSpatialDifferencing 2
2 numberOfOctetsExtraDescriptors 2
2 md5Section5 BYTEARRAY[16]
2 lengthOfHeaders 176
2 md5Headers BYTEARRAY[16]
2 sectionNumber LONGARRAY[7]
2 grib 2 Section 6 BIT-MAP SECTION
2 section6Length 6
2 numberOfSection LONGARRAY[6]
2 bitMapIndicator 255
2 bitmapPresent 0
2 md5Section6 BYTEARRAY[16]
2 sectionNumber LONGARRAY[7]
2 grib 2 Section 7 data
2 section7Length 52253
2 numberOfSection LONGARRAY[6]
2 codedValues DOUBLEARRAY[65160]
2 values DOUBLEARRAY[65160]
2 maximum 41.824994
2 minimum -45.375006
2 average 0.77840243
2 numberOfMissing 0
2 standardDeviation 6.9963328
2 skewness 7886167.8
2 kurtosis 6.6687206e+008
2 isConstant 0.00000000
2 changeDecimalPrecision 1
2 decimalPrecision 1
2 setBitsPerValue 11
2 getNumberOfValues 65160
2 scaleValuesBy 1.0000000
2 offsetValuesBy 0.00000000
2 productType 'unknown'
2 md5Section7 BYTEARRAY[16]
2 section8Length 4
2 7777 '7777'
总是没办法查看grib数据里面的变量。。。。
|
|