Merge branch 'develop' into feature/concepts_local_master_dir

This commit is contained in:
Shahram Najm 2020-07-14 19:33:17 +01:00
commit dae93ea523
167 changed files with 2209 additions and 22150 deletions

View File

@ -2,7 +2,7 @@
# general configuration #
#---------------------------------#
version: 2.18.0-{build}-{branch}
version: 2.19.0-{build}-{branch}
branches:
only:

View File

@ -18,7 +18,7 @@
cmake_minimum_required( VERSION 3.6 FATAL_ERROR )
project( eccodes VERSION 2.18.0 LANGUAGES C )
project( eccodes VERSION 2.19.0 LANGUAGES C )
set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild/cmake" )
@ -119,7 +119,7 @@ ecbuild_add_option( FEATURE AEC
ecbuild_add_option( FEATURE PYTHON
DESCRIPTION "Build the ecCodes Python2 interface (deprecated)"
DEFAULT ON
DEFAULT OFF
REQUIRED_PACKAGES "Python VERSION 2.6 NO_LIBS" NumPy )
# For Python2 we build our own bindings (using SWIG) in the build directory
# but for Python3 one has to add the eccodes from pip3 AFTER the install
@ -418,7 +418,7 @@ ecbuild_dont_pack( DIRS
concepts tests.ecmwf doxygen confluence examples.dev templates parameters java
perl config m4 rpms gaussian_experimental gribex examples/F77
examples/extra examples/deprecated bamboo fortran/fortranCtypes tigge/tools
share/eccodes .settings python3 )
share/eccodes .settings )
#ecbuild_dont_pack( DIRS data/bufr DONT_PACK_REGEX "*.bufr" )
#ecbuild_dont_pack( DIRS data/tigge DONT_PACK_REGEX "*.grib" )

View File

@ -64,6 +64,7 @@ EXTRA_DIST = README AUTHORS NOTICE LICENSE ChangeLog version.sh html \
data/scan_y_rotated_ll_8_4_good.dump \
data/scan_y_rotated_ll_8_7_good.dump \
data/tigge_pf_ecmwf.grib2.ref \
data/BUFR3.tmpl.dump.plain.ref
data/60_model_levels \
data/list_points \
data/step.log \

View File

@ -0,0 +1,135 @@
delayedDescriptorReplicationFactor= {
1, 1}
edition=3
masterTableNumber=0
bufrHeaderSubCentre=0
bufrHeaderCentre=98
updateSequenceNumber=0
dataCategory=1
dataSubCategory=110
masterTablesVersionNumber=24
localTablesVersionNumber=0
typicalYearOfCentury=12
typicalMonth=10
typicalDay=31
typicalHour=0
typicalMinute=2
numberOfSubsets=1
observedData=1
compressedData=0
unexpandedDescriptors=307080
blockNumber=MISSING
stationNumber=MISSING
stationOrSiteName=MISSING
stationType=MISSING
year=MISSING
month=MISSING
day=MISSING
hour=MISSING
minute=MISSING
latitude=MISSING
longitude=MISSING
heightOfStationGroundAboveMeanSeaLevel=MISSING
heightOfBarometerAboveMeanSeaLevel=MISSING
nonCoordinatePressure=MISSING
pressureReducedToMeanSeaLevel=MISSING
3HourPressureChange=MISSING
characteristicOfPressureTendency=MISSING
24HourPressureChange=MISSING
pressure=MISSING
nonCoordinateGeopotentialHeight=MISSING
#1#heightOfSensorAboveLocalGroundOrDeckOfMarinePlatform=MISSING
airTemperature=MISSING
dewpointTemperature=MISSING
relativeHumidity=MISSING
#2#heightOfSensorAboveLocalGroundOrDeckOfMarinePlatform=MISSING
horizontalVisibility=MISSING
#3#heightOfSensorAboveLocalGroundOrDeckOfMarinePlatform=MISSING
totalPrecipitationPast24Hours=MISSING
#4#heightOfSensorAboveLocalGroundOrDeckOfMarinePlatform=MISSING
cloudCoverTotal=MISSING
#1#verticalSignificanceSurfaceObservations=MISSING
#1#cloudAmount=MISSING
#1#heightOfBaseOfCloud=MISSING
#1#cloudType=MISSING
#2#cloudType=MISSING
#3#cloudType=MISSING
#2#verticalSignificanceSurfaceObservations=MISSING
#2#cloudAmount=MISSING
#4#cloudType=MISSING
#2#heightOfBaseOfCloud=MISSING
#3#verticalSignificanceSurfaceObservations=MISSING
#3#cloudAmount=MISSING
#5#cloudType=MISSING
heightOfTopOfCloud=MISSING
cloudTopDescription=MISSING
#4#verticalSignificanceSurfaceObservations=MISSING
#1#trueDirectionFromWhichAPhenomenonOrCloudsAreMovingOrInWhichTheyAreObserved=MISSING
#5#verticalSignificanceSurfaceObservations=MISSING
#2#trueDirectionFromWhichAPhenomenonOrCloudsAreMovingOrInWhichTheyAreObserved=MISSING
#6#verticalSignificanceSurfaceObservations=MISSING
#3#trueDirectionFromWhichAPhenomenonOrCloudsAreMovingOrInWhichTheyAreObserved=MISSING
#7#verticalSignificanceSurfaceObservations=MISSING
#1#bearingOrAzimuth=MISSING
#1#elevation=MISSING
#6#cloudType=MISSING
#2#bearingOrAzimuth=MISSING
#2#elevation=MISSING
stateOfGround=MISSING
totalSnowDepth=MISSING
groundMinimumTemperaturePast12Hours=MISSING
presentWeather=MISSING
#1#timePeriod=MISSING
pastWeather1=MISSING
pastWeather2=MISSING
#2#timePeriod=MISSING
#1#totalSunshine=MISSING
#3#timePeriod=MISSING
#2#totalSunshine=MISSING
#5#heightOfSensorAboveLocalGroundOrDeckOfMarinePlatform=MISSING
#4#timePeriod=MISSING
#1#totalPrecipitationOrTotalWaterEquivalent=MISSING
#5#timePeriod=MISSING
#2#totalPrecipitationOrTotalWaterEquivalent=MISSING
#6#heightOfSensorAboveLocalGroundOrDeckOfMarinePlatform=MISSING
#6#timePeriod=MISSING
#7#timePeriod=MISSING
maximumTemperatureAtHeightAndOverPeriodSpecified=MISSING
#8#timePeriod=MISSING
#9#timePeriod=MISSING
minimumTemperatureAtHeightAndOverPeriodSpecified=MISSING
#7#heightOfSensorAboveLocalGroundOrDeckOfMarinePlatform=MISSING
instrumentationForWindMeasurement=MISSING
#1#timeSignificance=MISSING
#10#timePeriod=MISSING
windDirection=MISSING
windSpeed=MISSING
#2#timeSignificance=MISSING
#11#timePeriod=MISSING
#1#maximumWindGustDirection=MISSING
#1#maximumWindGustSpeed=MISSING
#12#timePeriod=MISSING
#2#maximumWindGustDirection=MISSING
#2#maximumWindGustSpeed=MISSING
#8#heightOfSensorAboveLocalGroundOrDeckOfMarinePlatform=MISSING
#13#timePeriod=MISSING
typeOfInstrumentationForEvaporationMeasurement=MISSING
evaporation=MISSING
#14#timePeriod=MISSING
#1#longWaveRadiationIntegratedOverPeriodSpecified=MISSING
#1#shortWaveRadiationIntegratedOverPeriodSpecified=MISSING
#1#netRadiationIntegratedOverPeriodSpecified=MISSING
#1#globalSolarRadiationIntegratedOverPeriodSpecified=MISSING
#1#diffuseSolarRadiationIntegratedOverPeriodSpecified=MISSING
#1#directSolarRadiationIntegratedOverPeriodSpecified=MISSING
#15#timePeriod=MISSING
#2#longWaveRadiationIntegratedOverPeriodSpecified=MISSING
#2#shortWaveRadiationIntegratedOverPeriodSpecified=MISSING
#2#netRadiationIntegratedOverPeriodSpecified=MISSING
#2#globalSolarRadiationIntegratedOverPeriodSpecified=MISSING
#2#diffuseSolarRadiationIntegratedOverPeriodSpecified=MISSING
#2#directSolarRadiationIntegratedOverPeriodSpecified=MISSING
#16#timePeriod=MISSING
#17#timePeriod=MISSING
temperatureChangeOverSpecifiedPeriod=MISSING

View File

@ -61,6 +61,7 @@ list(APPEND other_files
typeOfProcessedData.ok
tigge_pf_ecmwf.grib2.ref
grib_data_files.txt
BUFR3.tmpl.dump.plain.ref
)
foreach( file ${other_files} )

View File

@ -11,18 +11,22 @@ meta localMinute bits(keyData,27,6) : dump,long_type,no_copy;
meta localSecond bits(keyData,33,6) : dump,long_type,no_copy;
meta spare bits(keyData,39,1) : no_copy; # 40 bits = 5 bytes
alias mars.localYear=localYear;
alias mars.localMonth=localMonth;
alias mars.localDay=localDay;
alias mars.localHour=localHour;
alias mars.localMinute=localMinute;
alias mars.localSecond=localSecond;
alias rdb.localYear=localYear;
alias rdb.localMonth=localMonth;
alias rdb.localDay=localDay;
alias rdb.localHour=localHour;
alias rdb.localMinute=localMinute;
alias rdb.localSecond=localSecond;
meta localDate sprintf("%.4d%.2d%.2d",localYear,localMonth,localDay) : no_copy,read_only;
meta localTime sprintf("%.2d%.2d",localHour,localMinute) : no_copy,read_only;
meta localDateTime julian_date(localYear,localMonth,localDay,localHour,localMinute,localSecond) : no_copy;
alias mars.date = localDate;
alias mars.time = localTime;
# isSatellite and other stuff moved to section 3
ascii[8] keyMore : hidden;
byte[9] keySat : hidden;
ascii[8] keyMore : hidden;
byte[9] keySat : hidden;
# 16 bytes
unsigned[2] messageLength;
@ -80,9 +84,10 @@ if (oldSubtype < 255 ) {
alias ls.rdbType=rdbType;
alias ls.rdbSubtype=rdbSubtype;
alias mars.rdbType=rdbType;
alias mars.rdbSubtype=rdbSubtype;
alias rdb.rdbType=rdbType;
alias rdb.rdbSubtype=rdbSubtype;
alias mars.obstype = rdbSubtype;
#Data assimilation loop for purpose of Continous DA
unsigned[1] daLoop;

View File

@ -75,19 +75,15 @@ if (section2Present && bufrHeaderCentre==98 && section2Length==52) {
oldSubtype==31) {
meta ls.localNumberOfObservations bits(keySat,0,16) : dump,long_type,no_copy;
meta ls.satelliteID bits(keySat,16,16) : dump,long_type,no_copy;
alias mars.satelliteID=satelliteID;
} else {
meta ls.localNumberOfObservations bits(keySat,0,8) : dump,long_type,no_copy;
meta ls.satelliteID bits(keySat,8,16) : dump,long_type,no_copy;
alias mars.satelliteID=satelliteID;
}
} else {
meta ls.localLatitude bits(keyData,72,25,-9000000,100000) : dump,no_copy;
meta ls.localLongitude bits(keyData,40,26,-18000000,100000) : dump,no_copy;
alias ls.ident=keyMore : dump,string_type,no_copy;
alias mars.localLatitude=localLatitude;
alias mars.localLongitude=localLongitude;
meta ident trim(keyMore,1,1): dump, no_copy; # remove whitespaces left and right
alias mars.ident = ident : string_type, no_copy;
}
}

View File

@ -246,3 +246,11 @@
scaledValueOfFirstFixedSurface = 0 ;
scaleFactorOfFirstFixedSurface = 0 ;
}
#Top net solar radiation
'toa_net_upward_shortwave_flux' = {
discipline = 0 ;
parameterCategory = 4 ;
parameterNumber = 1 ;
typeOfFirstFixedSurface = 8 ;
typeOfStatisticalProcessing = 1 ;
}

View File

@ -205,6 +205,22 @@
parameterCategory = 2 ;
parameterNumber = 32 ;
}
#Total column cloud liquid water
'tclw' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 69 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 8 ;
}
#Total column cloud ice water
'tciw' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 70 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 8 ;
}
#Surface solar radiation downwards
'ssrd' = {
discipline = 0 ;
@ -221,6 +237,14 @@
typeOfStatisticalProcessing = 1 ;
typeOfFirstFixedSurface = 1 ;
}
#Top net solar radiation
'tsr' = {
discipline = 0 ;
parameterCategory = 4 ;
parameterNumber = 1 ;
typeOfFirstFixedSurface = 8 ;
typeOfStatisticalProcessing = 1 ;
}
#Eastward turbulent surface stress
'ewss' = {
discipline = 0 ;
@ -475,6 +499,16 @@
typeOfFirstFixedSurface = 169 ;
typeOfSecondFixedSurface = 255 ;
}
#2 metre specific humidity
'sh2' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 0 ;
typeOfFirstFixedSurface = 103 ;
typeOfSecondFixedSurface = 255 ;
scaledValueOfFirstFixedSurface = 2 ;
scaleFactorOfFirstFixedSurface = 0 ;
}
#Ammonium aerosol mass mixing ratio
'aermr18' = {
discipline = 0 ;
@ -943,6 +977,33 @@
parameterNumber = 20 ;
typeOfStatisticalProcessing = 0 ;
}
#Time integral of rain flux
'tirf' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 65 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 255 ;
typeOfStatisticalProcessing = 1 ;
}
#Time integral of surface eastward momentum flux
'tisemf' = {
discipline = 0 ;
parameterCategory = 2 ;
parameterNumber = 17 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 255 ;
typeOfStatisticalProcessing = 1 ;
}
#Time integral of surface northward momentum flux
'tisnmf' = {
discipline = 0 ;
parameterCategory = 2 ;
parameterNumber = 18 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 255 ;
typeOfStatisticalProcessing = 1 ;
}
#Cross sectional area of flow in channel
'chcross' = {
discipline = 1 ;
@ -1047,6 +1108,14 @@
parameterCategory = 0 ;
parameterNumber = 9 ;
}
#Total column graupel
'tcolg' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 74 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 8 ;
}
#2 metre relative humidity
'r2' = {
discipline = 0 ;

View File

@ -109,12 +109,6 @@
parameterCategory = 128 ;
parameterNumber = 174 ;
}
#Top net solar radiation
'toa_net_upward_shortwave_flux' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 178 ;
}
#Evaporation
'lwe_thickness_of_water_evaporation_amount' = {
discipline = 192 ;

View File

@ -40,3 +40,9 @@
parameterCategory = 151 ;
parameterNumber = 163 ;
}
#Top net solar radiation
'toa_net_upward_shortwave_flux' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 178 ;
}

View File

@ -395,18 +395,6 @@
parameterCategory = 128 ;
parameterNumber = 74 ;
}
#Total column cloud liquid water
'tclw' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 78 ;
}
#Total column cloud ice water
'tciw' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 79 ;
}
#Experimental product
'p80.128' = {
discipline = 192 ;
@ -830,12 +818,6 @@
parameterCategory = 128 ;
parameterNumber = 174 ;
}
#Top net solar radiation
'tsr' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 178 ;
}
#Evaporation
'e' = {
discipline = 192 ;

View File

@ -118,3 +118,21 @@
parameterCategory = 131 ;
parameterNumber = 88 ;
}
#Total column cloud liquid water
'tclw' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 78 ;
}
#Total column cloud ice water
'tciw' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 79 ;
}
#Top net solar radiation
'tsr' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 178 ;
}

View File

@ -395,18 +395,6 @@
parameterCategory = 128 ;
parameterNumber = 74 ;
}
#Total column cloud liquid water
'Total column cloud liquid water' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 78 ;
}
#Total column cloud ice water
'Total column cloud ice water' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 79 ;
}
#Experimental product
'Experimental product' = {
discipline = 192 ;
@ -830,12 +818,6 @@
parameterCategory = 128 ;
parameterNumber = 174 ;
}
#Top net solar radiation
'Top net solar radiation' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 178 ;
}
#Evaporation
'Evaporation' = {
discipline = 192 ;

View File

@ -118,3 +118,21 @@
parameterCategory = 131 ;
parameterNumber = 88 ;
}
#Total column cloud liquid water
'Total column cloud liquid water' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 78 ;
}
#Total column cloud ice water
'Total column cloud ice water' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 79 ;
}
#Top net solar radiation
'Top net solar radiation' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 178 ;
}

View File

@ -395,18 +395,6 @@
parameterCategory = 128 ;
parameterNumber = 74 ;
}
#Total column cloud liquid water
'78' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 78 ;
}
#Total column cloud ice water
'79' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 79 ;
}
#Experimental product
'80' = {
discipline = 192 ;
@ -830,12 +818,6 @@
parameterCategory = 128 ;
parameterNumber = 174 ;
}
#Top net solar radiation
'178' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 178 ;
}
#Evaporation
'182' = {
discipline = 192 ;

View File

@ -118,3 +118,21 @@
parameterCategory = 131 ;
parameterNumber = 88 ;
}
#Total column cloud liquid water
'78' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 78 ;
}
#Total column cloud ice water
'79' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 79 ;
}
#Top net solar radiation
'178' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 178 ;
}

View File

@ -395,18 +395,6 @@
parameterCategory = 128 ;
parameterNumber = 74 ;
}
#Total column cloud liquid water
'tclw' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 78 ;
}
#Total column cloud ice water
'tciw' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 79 ;
}
#Experimental product
'~' = {
discipline = 192 ;
@ -830,12 +818,6 @@
parameterCategory = 128 ;
parameterNumber = 174 ;
}
#Top net solar radiation
'tsr' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 178 ;
}
#Evaporation
'e' = {
discipline = 192 ;

View File

@ -118,3 +118,21 @@
parameterCategory = 131 ;
parameterNumber = 88 ;
}
#Total column cloud liquid water
'tclw' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 78 ;
}
#Total column cloud ice water
'tciw' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 79 ;
}
#Top net solar radiation
'tsr' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 178 ;
}

View File

@ -395,18 +395,6 @@
parameterCategory = 128 ;
parameterNumber = 74 ;
}
#Total column cloud liquid water
'kg m**-2' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 78 ;
}
#Total column cloud ice water
'kg m**-2' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 79 ;
}
#Experimental product
'~' = {
discipline = 192 ;
@ -830,12 +818,6 @@
parameterCategory = 128 ;
parameterNumber = 174 ;
}
#Top net solar radiation
'J m**-2' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 178 ;
}
#Evaporation
'm of water equivalent' = {
discipline = 192 ;

View File

@ -118,3 +118,21 @@
parameterCategory = 131 ;
parameterNumber = 88 ;
}
#Total column cloud liquid water
'kg m**-2' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 78 ;
}
#Total column cloud ice water
'kg m**-2' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 79 ;
}
#Top net solar radiation
'J m**-2' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 178 ;
}

View File

@ -72,3 +72,13 @@
scaledValueOfFirstFixedSurface = 15 ;
scaleFactorOfFirstFixedSurface = 1 ;
}
#2 metre specific humidity
'sh2' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 0 ;
typeOfFirstFixedSurface = 103 ;
typeOfSecondFixedSurface = 255 ;
scaledValueOfFirstFixedSurface = 15 ;
scaleFactorOfFirstFixedSurface = 1 ;
}

View File

@ -72,3 +72,13 @@
scaleFactorOfFirstFixedSurface = 1 ;
typeOfFirstFixedSurface = 103 ;
}
#2 metre specific humidity
'2 metre specific humidity' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 0 ;
typeOfFirstFixedSurface = 103 ;
typeOfSecondFixedSurface = 255 ;
scaledValueOfFirstFixedSurface = 15 ;
scaleFactorOfFirstFixedSurface = 1 ;
}

View File

@ -72,3 +72,13 @@
scaledValueOfFirstFixedSurface = 15 ;
scaleFactorOfFirstFixedSurface = 1 ;
}
#2 metre specific humidity
'174096' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 0 ;
typeOfFirstFixedSurface = 103 ;
typeOfSecondFixedSurface = 255 ;
scaledValueOfFirstFixedSurface = 15 ;
scaleFactorOfFirstFixedSurface = 1 ;
}

View File

@ -72,3 +72,13 @@
scaledValueOfFirstFixedSurface = 15 ;
scaleFactorOfFirstFixedSurface = 1 ;
}
#2 metre specific humidity
'2sh' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 0 ;
typeOfFirstFixedSurface = 103 ;
typeOfSecondFixedSurface = 255 ;
scaledValueOfFirstFixedSurface = 15 ;
scaleFactorOfFirstFixedSurface = 1 ;
}

View File

@ -72,3 +72,13 @@
scaleFactorOfFirstFixedSurface = 1 ;
typeOfFirstFixedSurface = 103 ;
}
#2 metre specific humidity
'kg kg**-1' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 0 ;
typeOfFirstFixedSurface = 103 ;
typeOfSecondFixedSurface = 255 ;
scaledValueOfFirstFixedSurface = 15 ;
scaleFactorOfFirstFixedSurface = 1 ;
}

View File

@ -205,6 +205,22 @@
parameterCategory = 2 ;
parameterNumber = 32 ;
}
#Total column cloud liquid water
'Total column cloud liquid water' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 69 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 8 ;
}
#Total column cloud ice water
'Total column cloud ice water' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 70 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 8 ;
}
#Surface solar radiation downwards
'Surface solar radiation downwards' = {
discipline = 0 ;
@ -221,6 +237,14 @@
typeOfStatisticalProcessing = 1 ;
typeOfFirstFixedSurface = 1 ;
}
#Top net solar radiation
'Top net solar radiation' = {
discipline = 0 ;
parameterCategory = 4 ;
parameterNumber = 1 ;
typeOfFirstFixedSurface = 8 ;
typeOfStatisticalProcessing = 1 ;
}
#Eastward turbulent surface stress
'Eastward turbulent surface stress' = {
discipline = 0 ;
@ -475,6 +499,16 @@
typeOfSecondFixedSurface = 255 ;
scaleFactorOfFirstFixedSurface = 2 ;
}
#2 metre specific humidity
'2 metre specific humidity' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 0 ;
typeOfFirstFixedSurface = 103 ;
typeOfSecondFixedSurface = 255 ;
scaledValueOfFirstFixedSurface = 2 ;
scaleFactorOfFirstFixedSurface = 0 ;
}
#Ammonium aerosol mass mixing ratio
'Ammonium aerosol mass mixing ratio' = {
discipline = 0 ;
@ -943,6 +977,33 @@
parameterNumber = 20 ;
typeOfStatisticalProcessing = 0 ;
}
#Time integral of rain flux
'Time integral of rain flux' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 65 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 255 ;
typeOfStatisticalProcessing = 1 ;
}
#Time integral of surface eastward momentum flux
'Time integral of surface eastward momentum flux' = {
discipline = 0 ;
parameterCategory = 2 ;
parameterNumber = 17 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 255 ;
typeOfStatisticalProcessing = 1 ;
}
#Time integral of surface northward momentum flux
'Time integral of surface northward momentum flux' = {
discipline = 0 ;
parameterCategory = 2 ;
parameterNumber = 18 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 255 ;
typeOfStatisticalProcessing = 1 ;
}
#Cross sectional area of flow in channel
'Cross sectional area of flow in channel' = {
discipline = 1 ;
@ -1047,6 +1108,14 @@
parameterCategory = 0 ;
parameterNumber = 9 ;
}
#Total column graupel
'Total column graupel' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 74 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 8 ;
}
#2 metre relative humidity
'2 metre relative humidity' = {
discipline = 0 ;

View File

@ -205,6 +205,22 @@
parameterCategory = 2 ;
parameterNumber = 32 ;
}
#Total column cloud liquid water
'78' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 69 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 8 ;
}
#Total column cloud ice water
'79' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 70 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 8 ;
}
#Surface solar radiation downwards
'169' = {
discipline = 0 ;
@ -221,6 +237,14 @@
typeOfFirstFixedSurface = 1 ;
typeOfStatisticalProcessing = 1 ;
}
#Top net solar radiation
'178' = {
discipline = 0 ;
parameterCategory = 4 ;
parameterNumber = 1 ;
typeOfFirstFixedSurface = 8 ;
typeOfStatisticalProcessing = 1 ;
}
#Eastward turbulent surface stress
'180' = {
discipline = 0 ;
@ -475,6 +499,16 @@
typeOfFirstFixedSurface = 169 ;
scaledValueOfFirstFixedSurface = 1 ;
}
#2 metre specific humidity
'174096' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 0 ;
typeOfFirstFixedSurface = 103 ;
typeOfSecondFixedSurface = 255 ;
scaledValueOfFirstFixedSurface = 2 ;
scaleFactorOfFirstFixedSurface = 0 ;
}
#Ammonium aerosol mass mixing ratio
'210249' = {
discipline = 0 ;
@ -943,6 +977,33 @@
parameterNumber = 20 ;
typeOfStatisticalProcessing = 0 ;
}
#Time integral of rain flux
'235015' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 65 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 255 ;
typeOfStatisticalProcessing = 1 ;
}
#Time integral of surface eastward momentum flux
'235017' = {
discipline = 0 ;
parameterCategory = 2 ;
parameterNumber = 17 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 255 ;
typeOfStatisticalProcessing = 1 ;
}
#Time integral of surface northward momentum flux
'235018' = {
discipline = 0 ;
parameterCategory = 2 ;
parameterNumber = 18 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 255 ;
typeOfStatisticalProcessing = 1 ;
}
#Cross sectional area of flow in channel
'240011' = {
discipline = 1 ;
@ -1047,6 +1108,14 @@
parameterCategory = 0 ;
parameterNumber = 9 ;
}
#Total column graupel
'260001' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 74 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 8 ;
}
#2 metre relative humidity
'260242' = {
discipline = 0 ;

View File

@ -205,6 +205,22 @@
parameterCategory = 2 ;
parameterNumber = 32 ;
}
#Total column cloud liquid water
'tclw' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 69 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 8 ;
}
#Total column cloud ice water
'tciw' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 70 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 8 ;
}
#Surface solar radiation downwards
'ssrd' = {
discipline = 0 ;
@ -221,6 +237,14 @@
typeOfStatisticalProcessing = 1 ;
typeOfFirstFixedSurface = 1 ;
}
#Top net solar radiation
'tsr' = {
discipline = 0 ;
parameterCategory = 4 ;
parameterNumber = 1 ;
typeOfFirstFixedSurface = 8 ;
typeOfStatisticalProcessing = 1 ;
}
#Eastward turbulent surface stress
'ewss' = {
discipline = 0 ;
@ -475,6 +499,16 @@
scaleFactorOfFirstFixedSurface = 2 ;
typeOfFirstFixedSurface = 169 ;
}
#2 metre specific humidity
'2sh' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 0 ;
typeOfFirstFixedSurface = 103 ;
typeOfSecondFixedSurface = 255 ;
scaledValueOfFirstFixedSurface = 2 ;
scaleFactorOfFirstFixedSurface = 0 ;
}
#Ammonium aerosol mass mixing ratio
'aermr18' = {
discipline = 0 ;
@ -943,6 +977,33 @@
parameterNumber = 20 ;
typeOfStatisticalProcessing = 0 ;
}
#Time integral of rain flux
'tirf' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 65 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 255 ;
typeOfStatisticalProcessing = 1 ;
}
#Time integral of surface eastward momentum flux
'tisemf' = {
discipline = 0 ;
parameterCategory = 2 ;
parameterNumber = 17 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 255 ;
typeOfStatisticalProcessing = 1 ;
}
#Time integral of surface northward momentum flux
'tisnmf' = {
discipline = 0 ;
parameterCategory = 2 ;
parameterNumber = 18 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 255 ;
typeOfStatisticalProcessing = 1 ;
}
#Cross sectional area of flow in channel
'chcross' = {
discipline = 1 ;
@ -1047,6 +1108,14 @@
parameterCategory = 0 ;
parameterNumber = 9 ;
}
#Total column graupel
'tcolg' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 74 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 8 ;
}
#2 metre relative humidity
'2r' = {
discipline = 0 ;

View File

@ -205,6 +205,22 @@
parameterCategory = 2 ;
parameterNumber = 32 ;
}
#Total column cloud liquid water
'kg m**-2' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 69 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 8 ;
}
#Total column cloud ice water
'kg m**-2' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 70 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 8 ;
}
#Surface solar radiation downwards
'J m**-2' = {
discipline = 0 ;
@ -221,6 +237,14 @@
typeOfStatisticalProcessing = 1 ;
typeOfFirstFixedSurface = 1 ;
}
#Top net solar radiation
'J m**-2' = {
discipline = 0 ;
parameterCategory = 4 ;
parameterNumber = 1 ;
typeOfFirstFixedSurface = 8 ;
typeOfStatisticalProcessing = 1 ;
}
#Eastward turbulent surface stress
'N m**-2 s' = {
discipline = 0 ;
@ -475,6 +499,16 @@
typeOfSecondFixedSurface = 255 ;
scaleFactorOfFirstFixedSurface = 2 ;
}
#2 metre specific humidity
'kg kg**-1' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 0 ;
typeOfFirstFixedSurface = 103 ;
typeOfSecondFixedSurface = 255 ;
scaledValueOfFirstFixedSurface = 2 ;
scaleFactorOfFirstFixedSurface = 0 ;
}
#Ammonium aerosol mass mixing ratio
'kg kg**-1' = {
discipline = 0 ;
@ -943,6 +977,33 @@
parameterNumber = 20 ;
typeOfStatisticalProcessing = 0 ;
}
#Time integral of rain flux
'kg m**-2' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 65 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 255 ;
typeOfStatisticalProcessing = 1 ;
}
#Time integral of surface eastward momentum flux
'N m**-2 s' = {
discipline = 0 ;
parameterCategory = 2 ;
parameterNumber = 17 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 255 ;
typeOfStatisticalProcessing = 1 ;
}
#Time integral of surface northward momentum flux
'N m**-2 s' = {
discipline = 0 ;
parameterCategory = 2 ;
parameterNumber = 18 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 255 ;
typeOfStatisticalProcessing = 1 ;
}
#Cross sectional area of flow in channel
'm**2' = {
discipline = 1 ;
@ -1047,6 +1108,14 @@
parameterCategory = 0 ;
parameterNumber = 9 ;
}
#Total column graupel
'kg m**-2' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 74 ;
typeOfFirstFixedSurface = 1 ;
typeOfSecondFixedSurface = 8 ;
}
#2 metre relative humidity
'%' = {
discipline = 0 ;

View File

@ -0,0 +1,2 @@
alias mars.anoffset=offsetToEndOf4DvarWindow;
alias mars.number=componentIndex;

View File

@ -0,0 +1 @@
alias mars.number=componentIndex;

View File

@ -59,7 +59,7 @@ endforeach()
# Now add each test (shell scripts)
########################################################################
list(APPEND tests_basic
list(APPEND tests_sanity
grib_set_data
large_grib1
grib_sections_copy
@ -100,9 +100,10 @@ list(APPEND tests_extra
get_product_kind
)
foreach( test ${tests_basic} )
foreach( test ${tests_sanity} )
ecbuild_add_test( TARGET eccodes_c_${test}
TYPE SCRIPT
LABELS "sanity"
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh )
endforeach()
foreach( test ${tests_extra} )

View File

@ -7,7 +7,7 @@ execute_process( COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_S
# Build the executables used by test scripts
################################################
list( APPEND tests_basic
list( APPEND tests_sanity
grib_set_pv
grib_set_data
grib_ecc-671 )
@ -53,24 +53,25 @@ list( APPEND tests_extra
bufr_subset
get_product_kind )
foreach( tool ${tests_basic} )
ecbuild_add_test( TARGET eccodes_f_${tool}
SOURCES ${tool}.f90
foreach( tool ${tests_sanity} )
ecbuild_add_test( TARGET eccodes_f_${tool}
SOURCES ${tool}.f90
LINKER_LANGUAGE Fortran
LIBS eccodes_f90 eccodes
CONDITION HAVE_FORTRAN
RESOURCES bufr_read_scatterometer_f.ref
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${tool}.sh )
LIBS eccodes_f90 eccodes
CONDITION HAVE_FORTRAN
LABELS "sanity"
RESOURCES bufr_read_scatterometer_f.ref
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${tool}.sh )
endforeach()
foreach( tool ${tests_extra} )
ecbuild_add_test( TARGET eccodes_f_${tool}
SOURCES ${tool}.f90
ecbuild_add_test( TARGET eccodes_f_${tool}
SOURCES ${tool}.f90
LINKER_LANGUAGE Fortran
LIBS eccodes_f90 eccodes
CONDITION HAVE_FORTRAN AND ENABLE_EXTRA_TESTS
RESOURCES bufr_read_scatterometer_f.ref
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${tool}.sh
TEST_DEPENDS eccodes_download_gribs eccodes_download_bufrs )
LIBS eccodes_f90 eccodes
CONDITION HAVE_FORTRAN AND ENABLE_EXTRA_TESTS
RESOURCES bufr_read_scatterometer_f.ref
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${tool}.sh
TEST_DEPENDS eccodes_download_gribs eccodes_download_bufrs )
endforeach()
# Executables without a shell script

View File

@ -11,7 +11,11 @@
!
! Description: how to read data for a tropical cyclone BUFR message.
!
! Please note that tropical cyclone tracks can be encoded in various ways in BUFR.
! Therefore the code below might not work directly for other types of messages
! than the one used in the example. It is advised to use bufr_dump to
! understand the structure of the messages.
!
program bufr_read_tropical_cyclone
use eccodes
implicit none

View File

@ -12,7 +12,6 @@
#
# Description: how to read values of different type of keys from BUFR messages.
#
#
from __future__ import absolute_import
from __future__ import print_function

View File

@ -11,8 +11,8 @@
# Python implementation: bufr_keys_iterator
#
# Description: Example on how to use keys_iterator functions and the
# codes_bufr_keys_iterator structure to get all the available
# keys in a BUFR message.
# codes_bufr_keys_iterator structure to get all the available
# keys in a BUFR message.
from __future__ import print_function

View File

@ -10,6 +10,11 @@
#
# Description: how to read data of the ECMWF EPS tropical cyclone tracks encoded in BUFR format.
#
# Please note that tropical cyclone tracks can be encoded in various ways in BUFR.
# Therefore the code below might not work directly for other types of messages
# than the one used in the example. It is advised to use bufr_dump to
# understand the structure of the messages.
#
from __future__ import print_function
import traceback

View File

@ -25,7 +25,7 @@ if [ $HAVE_MEMFS -eq 1 ]; then
unset ECCODES_DEFINITION_PATH
fi
PYTHONPATH=@PROJECT_BINARY_DIR@/@ECCODES_PYTHON_DIR@:$PYTHONPATH
PYTHONPATH=@PROJECT_BINARY_DIR@/python:$PYTHONPATH
export PYTHONPATH
echo "Current directory: `pwd`"

View File

@ -1,86 +0,0 @@
if( HAVE_PYTHON )
#find_package( SWIG )
#if( SWIG_FOUND )
# include( ${SWIG_USE_FILE} )
#endif()
# preparing for generating setup.py
if( HAVE_LIBJASPER )
get_filename_component(JASPER_DIR ${JASPER_INCLUDE_DIR} PATH )
endif()
if( HAVE_LIBOPENJPEG )
# Get the name of the OpenJPEG library: version dependent!
# E.g. openjpeg (version 1.5) or openjp2 (version 2.x)
get_filename_component(OPENJPEG_LIB_DIR ${OPENJPEG_LIBRARY} PATH )
get_filename_component(OJ_NAME_WE ${OPENJPEG_LIBRARY} NAME_WE )
STRING(REGEX REPLACE "^lib" "" OJ_WITHOUT_LIB ${OJ_NAME_WE})
endif()
if( HAVE_AEC )
get_filename_component(AEC_DIR ${AEC_INCLUDE_DIR} PATH )
endif()
configure_file( setup.py.in setup.py )
# compile swig interface
# set(CMAKE_SWIG_FLAGS "")
# set_source_files_properties( gribapi_swig.i PROPERTIES C ON )
# if( NUMPY_FOUND )
# set( CMAKE_SWIG_FLAGS "-DNUMPY" )
# include_directories( ${NUMPY_INCLUDE_DIRS} )
# endif()
####### Do not invoke swig. Use our own generated C wrapper file ######
set( _gribapi_swig "gribapi/_gribapi_swig${CMAKE_SHARED_LIBRARY_SUFFIX}" )
# Build the extension module for use in build tree with RPATH pointing to the build tree
add_custom_command( OUTPUT ${_gribapi_swig}
COMMAND ${PYTHON_EXECUTABLE} setup.py build_ext --inplace --rpath ${CMAKE_BINARY_DIR}/lib
DEPENDS grib_interface.h grib_interface.c swig_wrap_numpy.c setup.py.in eccodes )
add_custom_target(eccodes_build_swig_wrapper ALL DEPENDS ${_gribapi_swig})
#ecbuild_add_library(TARGET _gribapi_swig
# TYPE SHARED
# NOINSTALL
# SOURCES grib_interface.h grib_interface.c swig_wrap_numpy.c
# INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${PYTHON_INCLUDE_DIRS}
# LIBS eccodes ${PYTHON_LIBRARIES} )
# Don't use the lib prefix. This is needed for the python case where a _modulename.so is generated
#set_target_properties(_gribapi_swig PROPERTIES PREFIX "")
# Copy gribapi and eccodes python modules to build area
file( COPY eccodes gribapi DESTINATION . )
configure_file( swig_wrap_numpy.py gribapi/gribapi_swig.py COPYONLY )
# Build the extension module for use in install tree with RPATH pointing to install tree
install(CODE "message(\"Building Python extension modules:
${PYTHON_EXECUTABLE} setup.py build_ext --rpath ${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}\")
execute_process(COMMAND ${PYTHON_EXECUTABLE} setup.py build_ext --rpath ${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")
# Library installation directory override
if( NOT INSTALL_LIB_DIR STREQUAL lib )
execute_process( COMMAND ${PYTHON_EXECUTABLE} -c "from __future__ import print_function; import sys; print(sys.version[:3], end='')"
OUTPUT_VARIABLE PYVER )
set( __install_lib "--install-lib=${ECCODES_FULL_INSTALL_LIB_DIR}/python${PYVER}/site-packages" )
endif()
# Call distutils for installation
install(CODE "if( NOT \$ENV{DESTDIR} STREQUAL \"\" )
set( __root \"--root=\$ENV{DESTDIR}\" )
endif()
message(\"Installing Python modules:
${PYTHON_EXECUTABLE} setup.py install \${__root}
${__install_lib}
--prefix=${CMAKE_INSTALL_PREFIX}
--record=${CMAKE_BINARY_DIR}/extra_install.txt\")
execute_process(COMMAND ${PYTHON_EXECUTABLE} setup.py install
\${__root}
--prefix=${CMAKE_INSTALL_PREFIX}
${__install_lib}
--record=${CMAKE_BINARY_DIR}/extra_install.txt
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")
endif()

View File

@ -1,5 +0,0 @@
# we use pre-generated files from SWIG - to recreate them use:
swig -python -module gribapi_swig -o swig_wrap_numpy.c gribapi_swig.i
cp gribapi_swig.py swig_wrap_numpy.py

View File

@ -1,111 +0,0 @@
#!/usr/bin/env perl
# This script is used to generate the file "python/gribapi/errors.py"
# It reads "src/grib_errors.c" which it expects to be up-to-date with
# all the error codes.
$|=1;
my $input = '../src/grib_errors.c';
my $print_class = 1;
my %errmap = ();
# Print header
# -------------------------------------
my $header = <<'END_HEADER';
"""
Exception class hierarchy
"""
import gribapi_swig as _internal
class GribInternalError(Exception):
"""
@brief Wrap errors coming from the C API in a Python exception object.
Base class for all exceptions
"""
def __init__(self, value):
# Call the base class constructor with the parameters it needs
Exception.__init__(self, value)
if type(value) is int:
err, self.msg = _internal.grib_c_get_error_string(value, 1024)
assert err == 0
else:
self.msg = value
def __str__(self):
return self.msg
END_HEADER
print $header;
# Print the exception classes
# -------------------------------------
while (<>) {
# Example of input line
# "Passed array is too small", /* -6 GRIB_ARRAY_TOO_SMALL */
if (/^"(.*)",\s+\/\* (.*) (.*) \*\//) {
$desc = $1;
$code = $2;
$name = $3;
next if ($code == 0);
$name =~ s/GRIB_//;
$name_lc = $name;
$name_lc =~ s/_/ /g;
$name_lc = lc $name_lc;
$name_lc =~ s/(\w+)/\u$1/g;
$name_lc =~ s/ //g;
$name = $name_lc;
if ($name !~ /Error$/) {
$name = $name . "Error";
}
$name = 'FunctionNotImplementedError' if ($name eq 'NotImplementedError');
$name = 'MessageEndNotFoundError' if ($name eq '7777NotFoundError');
$name = 'IOProblemError' if ($name eq 'IoProblemError');
$name = 'MessageInvalidError' if ($name eq 'InvalidMessageError');
$name = 'GeocalculusError' if ($name eq 'GeocalculusProblemError');
$name = 'InvalidOrderByError' if ($name eq 'InvalidOrderbyError');
$name = 'InvalidBitsPerValueError' if ($name eq 'InvalidBpvError');
$name = 'KeyValueNotFoundError' if ($name eq 'NotFoundError');
$name = 'MemoryAllocationError' if ($name eq 'OutOfMemoryError');
# Print the class declaration
print "class ${name}(GribInternalError):\n";
print " \"\"\"${desc}.\"\"\"\n";
$errmap{$code} = $name; # store for later
}
}
# Print the map
# -------------------------------------
my $size = keys %errmap;
print "\nERROR_MAP = {\n";
my $i = 0;
for $key (sort { $a <=> $b } keys %errmap) {
$i++;
my $ktext = sprintf("%-3d", $key);
print " $ktext : $errmap{$key}";
print ",\n" if ($i < $size);
}
print "\n}\n\n";
# Print footer
# -------------------------------------
my $footer = <<'END_FOOTER';
def raise_grib_error(errid):
"""
Raise the GribInternalError corresponding to ``errid``.
"""
raise ERROR_MAP[errid](errid)
END_FOOTER
print $footer;

View File

@ -1,11 +0,0 @@
from __future__ import absolute_import
import sys
from .eccodes import *
from .eccodes import __version__
if sys.version_info >= (2, 6):
from .high_level.gribfile import GribFile
from .high_level.gribmessage import GribMessage
from .high_level.gribindex import GribIndex
from .high_level.bufr import BufrFile, BufrMessage

View File

@ -1,111 +0,0 @@
from gribapi import __version__
from gribapi import GRIB_CHECK as CODES_CHECK
from gribapi import CODES_PRODUCT_GRIB
from gribapi import CODES_PRODUCT_BUFR
from gribapi import CODES_PRODUCT_GTS
from gribapi import CODES_PRODUCT_ANY
from gribapi import GRIB_MISSING_DOUBLE as CODES_MISSING_DOUBLE
from gribapi import GRIB_MISSING_LONG as CODES_MISSING_LONG
from gribapi import gts_new_from_file as codes_gts_new_from_file
from gribapi import metar_new_from_file as codes_metar_new_from_file
from gribapi import codes_new_from_file
from gribapi import any_new_from_file as codes_any_new_from_file
from gribapi import bufr_new_from_file as codes_bufr_new_from_file
from gribapi import grib_new_from_file as codes_grib_new_from_file
from gribapi import codes_close_file
from gribapi import grib_count_in_file as codes_count_in_file
from gribapi import grib_multi_support_on as codes_grib_multi_support_on
from gribapi import grib_multi_support_off as codes_grib_multi_support_off
from gribapi import grib_release as codes_release
from gribapi import grib_get_string as codes_get_string
from gribapi import grib_set_string as codes_set_string
from gribapi import grib_gribex_mode_on as codes_gribex_mode_on
from gribapi import grib_gribex_mode_off as codes_gribex_mode_off
from gribapi import grib_write as codes_write
from gribapi import grib_multi_write as codes_grib_multi_write
from gribapi import grib_multi_append as codes_grib_multi_append
from gribapi import grib_get_size as codes_get_size
from gribapi import grib_get_string_length as codes_get_string_length
from gribapi import grib_skip_computed as codes_skip_computed
from gribapi import grib_skip_coded as codes_skip_coded
from gribapi import grib_skip_edition_specific as codes_skip_edition_specific
from gribapi import grib_skip_duplicates as codes_skip_duplicates
from gribapi import grib_skip_read_only as codes_skip_read_only
from gribapi import grib_skip_function as codes_skip_function
from gribapi import grib_iterator_new as codes_grib_iterator_new
from gribapi import grib_iterator_delete as codes_grib_iterator_delete
from gribapi import grib_iterator_next as codes_grib_iterator_next
from gribapi import grib_keys_iterator_new as codes_keys_iterator_new
from gribapi import grib_keys_iterator_next as codes_keys_iterator_next
from gribapi import grib_keys_iterator_delete as codes_keys_iterator_delete
from gribapi import grib_keys_iterator_get_name as codes_keys_iterator_get_name
from gribapi import grib_keys_iterator_rewind as codes_keys_iterator_rewind
from gribapi import codes_bufr_keys_iterator_new
from gribapi import codes_bufr_keys_iterator_next
from gribapi import codes_bufr_keys_iterator_delete
from gribapi import codes_bufr_keys_iterator_get_name
from gribapi import codes_bufr_keys_iterator_rewind
from gribapi import grib_get_long as codes_get_long
from gribapi import grib_get_double as codes_get_double
from gribapi import grib_set_long as codes_set_long
from gribapi import grib_set_double as codes_set_double
from gribapi import grib_new_from_samples as codes_grib_new_from_samples
from gribapi import codes_bufr_new_from_samples
from gribapi import codes_new_from_samples
from gribapi import codes_bufr_copy_data
from gribapi import grib_clone as codes_clone
from gribapi import grib_set_double_array as codes_set_double_array
from gribapi import grib_get_double_array as codes_get_double_array
from gribapi import grib_get_string_array as codes_get_string_array
from gribapi import grib_set_string_array as codes_set_string_array
from gribapi import grib_set_long_array as codes_set_long_array
from gribapi import grib_get_long_array as codes_get_long_array
from gribapi import grib_multi_new as codes_grib_multi_new
from gribapi import grib_multi_release as codes_grib_multi_release
from gribapi import grib_copy_namespace as codes_copy_namespace
from gribapi import grib_index_new_from_file as codes_index_new_from_file
from gribapi import grib_index_add_file as codes_index_add_file
from gribapi import grib_index_release as codes_index_release
from gribapi import grib_index_get_size as codes_index_get_size
from gribapi import grib_index_get_long as codes_index_get_long
from gribapi import grib_index_get_string as codes_index_get_string
from gribapi import grib_index_get_double as codes_index_get_double
from gribapi import grib_index_select_long as codes_index_select_long
from gribapi import grib_index_select_double as codes_index_select_double
from gribapi import grib_index_select_string as codes_index_select_string
from gribapi import grib_new_from_index as codes_new_from_index
from gribapi import grib_get_message_size as codes_get_message_size
from gribapi import grib_get_message_offset as codes_get_message_offset
from gribapi import grib_get_double_element as codes_get_double_element
from gribapi import grib_get_double_elements as codes_get_double_elements
from gribapi import grib_get_elements as codes_get_elements
from gribapi import grib_set_missing as codes_set_missing
from gribapi import grib_set_key_vals as codes_set_key_vals
from gribapi import grib_is_missing as codes_is_missing
from gribapi import grib_is_defined as codes_is_defined
from gribapi import grib_find_nearest as codes_grib_find_nearest
from gribapi import grib_get_native_type as codes_get_native_type
from gribapi import grib_get as codes_get
from gribapi import grib_get_array as codes_get_array
from gribapi import grib_get_values as codes_get_values
from gribapi import grib_set_values as codes_set_values
from gribapi import grib_set as codes_set
from gribapi import grib_set_array as codes_set_array
from gribapi import grib_index_get as codes_index_get
from gribapi import grib_index_select as codes_index_select
from gribapi import grib_index_write as codes_index_write
from gribapi import grib_index_read as codes_index_read
from gribapi import grib_no_fail_on_wrong_length as codes_no_fail_on_wrong_length
from gribapi import grib_gts_header as codes_gts_header
from gribapi import grib_get_api_version as codes_get_api_version
from gribapi import grib_get_message as codes_get_message
from gribapi import grib_new_from_message as codes_new_from_message
from gribapi import grib_set_definitions_path as codes_set_definitions_path
from gribapi import grib_set_samples_path as codes_set_samples_path
from gribapi import GribInternalError as CodesInternalError
from gribapi.errors import *

View File

@ -1,97 +0,0 @@
"""
Classes for handling BUFR with a high level interface.
``BufrFiles`` can be treated mostly as regular files and used as context
managers, as can ``BufrMessages``. Each of these classes destructs itself and
any child instances appropriately.
Author: Daniel Lee, DWD, 2016
"""
from .. import eccodes
from .codesmessage import CodesMessage
from .codesfile import CodesFile
class BufrMessage(CodesMessage):
__doc__ = "\n".join(CodesMessage.__doc__.splitlines()[4:]).format(
prod_type="BUFR", classname="BufrMessage", parent="BufrFile",
alias="bufr")
product_kind = eccodes.CODES_PRODUCT_BUFR
# Arguments included explicitly to support introspection
# TODO: Can we get this to work with an index?
def __init__(self, codes_file=None, clone=None, sample=None,
headers_only=False):
"""
Open a message and inform the GRIB file that it's been incremented.
The message is taken from ``codes_file``, cloned from ``clone`` or
``sample``, or taken from ``index``, in that order of precedence.
"""
super(self.__class__, self).__init__(codes_file, clone, sample,
headers_only)
#self._unpacked = False
#def get(self, key, ktype=None):
# """Return requested value, unpacking data values if necessary."""
# # TODO: Only do this if accessing arrays that need unpacking
# if not self._unpacked:
# self.unpacked = True
# return super(self.__class__, self).get(key, ktype)
#def missing(self, key):
# """
# Report if key is missing.#
#
# Overloaded due to confusing behaviour in ``codes_is_missing`` (SUP-1874).
# """
# return not bool(eccodes.codes_is_defined(self.codes_id, key))
def unpack(self):
"""Decode data section"""
eccodes.codes_set(self.codes_id, 'unpack', 1)
def pack(self):
"""Encode data section"""
eccodes.codes_set(self.codes_id, 'pack', 1)
def keys(self, namespace=None):
#self.unpack()
#return super(self.__class__, self).keys(namespace)
iterator = eccodes.codes_bufr_keys_iterator_new(self.codes_id)
keys = []
while eccodes.codes_bufr_keys_iterator_next(iterator):
key = eccodes.codes_bufr_keys_iterator_get_name(iterator)
keys.append(key)
eccodes.codes_bufr_keys_iterator_delete(iterator)
return keys
#@property
#def unpacked(self):
# return self._unpacked
#@unpacked.setter
#def unpacked(self, val):
# eccodes.codes_set(self.codes_id, "unpack", val)
# self._unpacked = val
#def __setitem__(self, key, value):
# """Set item and pack BUFR."""
# if not self._unpacked:
# self.unpacked = True
# super(self.__class__, self).__setitem__(key, value)
# eccodes.codes_set(self.codes_id, "pack", True)
def copy_data(self, destMsg):
"""Copy data values from this message to another message"""
return eccodes.codes_bufr_copy_data(self.codes_id, destMsg.codes_id)
class BufrFile(CodesFile):
__doc__ = "\n".join(CodesFile.__doc__.splitlines()[4:]).format(
prod_type="BUFR", classname="BufrFile", alias="bufr")
MessageClass = BufrMessage

View File

@ -1,73 +0,0 @@
"""
``CodesFile`` class that implements a file that is readable by ecCodes and
closes itself and its messages when it is no longer needed.
Author: Daniel Lee, DWD, 2016
"""
from .. import eccodes
import io
class CodesFile(io.FileIO):
"""
An abstract class to specify and/or implement common behaviour that files
read by ecCodes should implement.
A {prod_type} file handle meant for use in a context manager.
Individual messages can be accessed using the ``next`` method. Of course,
it is also possible to iterate over each message in the file::
>>> with {classname}(filename) as {alias}:
... # Print number of messages in file
... len({alias})
... # Open all messages in file
... for msg in {alias}:
... print(msg[key_name])
... len({alias}.open_messages)
>>> # When the file is closed, any open messages are closed
>>> len({alias}.open_messages)
"""
#: Type of messages belonging to this file
MessageClass = None
def __init__(self, filename, mode="rb"):
"""Open file and receive codes file handle."""
#: File handle for working with actual file on disc
#: The class holds the file it works with because ecCodes'
# typechecking does not allow using inherited classes.
self.file_handle = open(filename, mode)
#: Number of message in file currently being read
self.message = 0
#: Open messages
self.open_messages = []
self.name = filename
def __exit__(self, exception_type, exception_value, traceback):
"""Close all open messages, release file handle and close file."""
while self.open_messages:
self.open_messages.pop().close()
eccodes.codes_close_file(self.file_handle)
#self.file_handle.close()
def __len__(self):
"""Return total number of messages in file."""
return eccodes.codes_count_in_file(self.file_handle)
def __enter__(self):
return self
def close(self):
"""Possibility to manually close file."""
self.__exit__(None, None, None)
def __iter__(self):
return self
def next(self):
try:
return self.MessageClass(self)
except IOError:
raise StopIteration()

View File

@ -1,184 +0,0 @@
"""
``CodesMessage`` class that implements a message readable by ecCodes that
allows access to the message's key-value pairs in a dictionary-like manner
and closes the message when it is no longer needed, coordinating this with
its host file.
Author: Daniel Lee, DWD, 2016
"""
from .. import eccodes
class CodesMessage(object):
"""
An abstract class to specify and/or implement common behaviour that
messages read by ecCodes should implement.
A {prod_type} message.
Each ``{classname}`` is stored as a key/value pair in a dictionary-like
structure. It can be used in a context manager or by itself. When the
``{parent}`` it belongs to is closed, the ``{parent}`` closes any open
``{classname}``s that belong to it. If a ``{classname}`` is closed before
its ``{parent}`` is closed, it informs the ``{parent}`` of its closure.
Scalar and vector values are set appropriately through the same method.
``{classname}``s can be instantiated from a ``{parent}``, cloned from
other ``{classname}``s or taken from samples. Iterating over the members
of a ``{parent}`` extracts the ``{classname}``s it contains until the
``{parent}`` is exhausted.
Usage::
>>> with {parent}(filename) as {alias}:
... # Access a key from each message
... for msg in {alias}:
... print(msg[key_name])
... # Report number of keys in message
... len(msg)
... # Report message size in bytes
... msg.size
... # Report keys in message
... msg.keys()
... # Set scalar value
... msg[scalar_key] = 5
... # Check key's value
... msg[scalar_key]
... msg[key_name]
... # Array values are set transparently
... msg[array_key] = [1, 2, 3]
... # Messages can be written to file
... with open(testfile, "w") as test:
... msg.write(test)
... # Messages can be cloned from other messages
... msg2 = {classname}(clone=msg)
... # If desired, messages can be closed manually or used in with
... msg.close()
"""
#: ecCodes enum-like PRODUCT constant
product_kind = None
def __init__(self, codes_file=None, clone=None, sample=None,
headers_only=False, other_args_found=False):
"""
Open a message and inform the host file that it's been incremented.
If ``codes_file`` is not supplied, the message is cloned from
``CodesMessage`` ``clone``. If neither is supplied,
the ``CodesMessage`` is cloned from ``sample``.
:param codes_file: A file readable for ecCodes
:param clone: A valid ``CodesMessage``
:param sample: A valid sample path to create ``CodesMessage`` from
"""
if not other_args_found and codes_file is None and clone is None and sample is None:
raise RuntimeError("CodesMessage initialization parameters not "
"present.")
#: Unique ID, for ecCodes interface
self.codes_id = None
#: File containing message
self.codes_file = None
if codes_file is not None:
self.codes_id = eccodes.codes_new_from_file(
codes_file.file_handle, self.product_kind, headers_only)
if self.codes_id is None:
raise IOError("CodesFile %s is exhausted" % codes_file.name)
self.codes_file = codes_file
self.codes_file.message += 1
self.codes_file.open_messages.append(self)
elif clone is not None:
self.codes_id = eccodes.codes_clone(clone.codes_id)
elif sample is not None:
self.codes_id = eccodes.codes_new_from_samples(
sample, self.product_kind)
def write(self, outfile=None):
"""Write message to file."""
if not outfile:
# This is a hack because the API does not accept inheritance
outfile = self.codes_file.file_handle
eccodes.codes_write(self.codes_id, outfile)
def __setitem__(self, key, value):
"""
Set value associated with key.
Iterables and scalars are handled intelligently.
"""
if isinstance(key, str):
if hasattr(value, "__iter__") and not isinstance(value, str):
eccodes.codes_set_array(self.codes_id, key, value)
else:
eccodes.codes_set(self.codes_id, key, value)
else:
if len(key) != len(value):
raise ValueError('Key array must have same size as value array')
eccodes.codes_set_key_vals(self.codes_id,",".join([str(key[i])+"="+str(value[i]) for i in range(len(key))]))
def keys(self, namespace=None):
"""Get available keys in message."""
iterator = eccodes.codes_keys_iterator_new(self.codes_id,
namespace=namespace)
keys = []
while eccodes.codes_keys_iterator_next(iterator):
key = eccodes.codes_keys_iterator_get_name(iterator)
keys.append(key)
eccodes.codes_keys_iterator_delete(iterator)
return keys
def size(self):
"""Return size of message in bytes."""
return eccodes.codes_get_message_size(self.codes_id)
def dump(self):
"""Dump message's binary content."""
return eccodes.codes_get_message(self.codes_id)
def get(self, key, ktype=None):
"""Get value of a given key as its native or specified type."""
# if self.missing(key):
# raise KeyError("Value of key %s is MISSING." % key)
if eccodes.codes_get_size(self.codes_id, key) > 1:
ret = eccodes.codes_get_array(self.codes_id, key, ktype)
else:
ret = eccodes.codes_get(self.codes_id, key, ktype)
return ret
def __exit__(self, exc_type, exc_val, exc_tb):
"""Release message handle and inform host file of release."""
eccodes.codes_release(self.codes_id)
def __enter__(self):
return self
def close(self):
"""Possibility to manually close message."""
self.__exit__(None, None, None)
def __contains__(self, key):
"""Check whether a key is present in message."""
return key in self.keys()
def __len__(self):
"""Return key count."""
return len(self.keys())
def __getitem__(self, key):
"""Return value associated with key as its native type."""
return self.get(key)
def __iter__(self):
return iter(self.keys())
# Not yet implemented
# def itervalues(self):
# return self.values()
def items(self):
"""Return list of tuples of all key/value pairs."""
return [(key, self[key]) for key in self.keys()]

View File

@ -1,17 +0,0 @@
"""
``GribFile`` class that implements a GRIB file that closes itself and its
messages when it is no longer needed.
Author: Daniel Lee, DWD, 2014
"""
from .codesfile import CodesFile
from .gribmessage import GribMessage
class GribFile(CodesFile):
__doc__ = "\n".join(CodesFile.__doc__.splitlines()[4:]).format(
prod_type="GRIB", classname="GribFile", alias="grib")
MessageClass = GribMessage

View File

@ -1,102 +0,0 @@
"""
``GribIndex`` class that implements a GRIB index that allows access to
ecCodes's index functionality.
Author: Daniel Lee, DWD, 2014
"""
from .. import eccodes
from .gribmessage import GribMessage
class GribIndex(object):
"""
A GRIB index meant for use in a context manager.
Usage::
>>> # Create index from file with keys
>>> with GribIndex(filename, keys) as idx:
... # Write index to file
... idx.write(index_file)
>>> # Read index from file
>>> with GribIndex(file_index=index_file) as idx:
... # Add new file to index
... idx.add(other_filename)
... # Report number of unique values for given key
... idx.size(key)
... # Report unique values indexed by key
... idx.values(key)
... # Request GribMessage matching key, value
... msg = idx.select({key: value})
"""
def __enter__(self):
return self
def __exit__(self, exception_type, exception_value, traceback):
"""Release GRIB message handle and inform file of release."""
while self.open_messages:
self.open_messages[0].close()
eccodes.codes_index_release(self.iid)
def close(self):
"""Possibility to manually close index."""
self.__exit__(None, None, None)
def __init__(self, filename=None, keys=None, file_index=None,
grib_index=None):
"""
Create new GRIB index over ``keys`` from ``filename``.
``filename`` should be a string of the desired file's filename.
``keys`` should be a sequence of keys to index. ``file_index`` should
be a string of the file that the index should be loaded from.
``grib_index`` should be another ``GribIndex``.
If ``filename`` and ``keys`` are provided, the ``GribIndex`` is
initialized over the given keys from the given file. If they are not
provided, the ``GribIndex`` is read from ``indexfile``. If
``grib_index`` is provided, it is cloned from the given ``GribIndex``.
"""
#: Grib index ID
self.iid = None
if filename and keys:
self.iid = eccodes.codes_index_new_from_file(filename, keys)
elif file_index:
self.iid = eccodes.codes_index_read(file_index)
elif grib_index:
self.iid = eccodes.codes_new_from_index(grib_index.iid)
else:
raise RuntimeError("No source was supplied "
"(possibilities: grib_file, clone, sample).")
#: Indexed keys. Only available if GRIB is initialized from file.
self.keys = keys
#: Open GRIB messages
self.open_messages = []
def size(self, key):
"""Return number of distinct values for index key."""
return eccodes.codes_index_get_size(self.iid, key)
def values(self, key, ktype=str):
"""Return distinct values of index key."""
return eccodes.codes_index_get(self.iid, key, ktype)
def add(self, filename):
"""Add ``filename`` to the ``GribIndex``."""
eccodes.codes_index_add_file(self.iid, filename)
def write(self, outfile):
"""Write index to filename at ``outfile``."""
eccodes.codes_index_write(self.iid, outfile)
def select(self, key_value_pairs):
"""
Return message associated with given key value pairs.
``key_value_pairs`` should be passed as a dictionary.
"""
for key in key_value_pairs:
eccodes.codes_index_select(self.iid, key, key_value_pairs[key])
return GribMessage(gribindex=self)

View File

@ -1,80 +0,0 @@
"""
``GribMessage`` class that implements a GRIB message that allows access to
the message's key-value pairs in a dictionary-like manner and closes the
message when it is no longer needed, coordinating this with its host file.
Author: Daniel Lee, DWD, 2014
"""
from .codesmessage import CodesMessage
from .. import eccodes
class IndexNotSelectedError(Exception):
"""GRIB index was requested before selecting key/value pairs."""
class GribMessage(CodesMessage):
__doc__ = "\n".join(CodesMessage.__doc__.splitlines()[4:]).format(
prod_type="GRIB", classname="GribMessage", parent="GribFile",
alias="grib")
product_kind = eccodes.CODES_PRODUCT_GRIB
# Arguments included explicitly to support introspection
def __init__(self, codes_file=None, clone=None, sample=None,
headers_only=False, gribindex=None):
"""
Open a message and inform the GRIB file that it's been incremented.
The message is taken from ``codes_file``, cloned from ``clone`` or
``sample``, or taken from ``index``, in that order of precedence.
"""
grib_args_present = True
if gribindex is None:
grib_args_present = False
super(self.__class__, self).__init__(codes_file, clone, sample,
headers_only, grib_args_present)
#: GribIndex referencing message
self.grib_index = None
if gribindex is not None:
self.codes_id = eccodes.codes_new_from_index(gribindex.iid)
if not self.codes_id:
raise IndexNotSelectedError("All keys must have selected "
"values before receiving message "
"from index.")
self.grib_index = gribindex
gribindex.open_messages.append(self)
def __exit__(self, exc_type, exc_val, exc_tb):
"""Release GRIB message handle and inform file of release."""
super(self.__class__, self).__exit__(exc_type, exc_val, exc_tb)
if self.grib_index:
self.grib_index.open_messages.remove(self)
def missing(self, key):
"""Report if the value of a key is MISSING."""
return bool(eccodes.codes_is_missing(self.codes_id, key))
def set_missing(self, key):
"""Set the value of key to MISSING."""
eccodes.codes_set_missing(self.codes_id, key)
@property
def gid(self):
"""Provided for backwards compatibility."""
return self.codes_id
@property
def grib_file(self):
"""Provided for backwards compatibility."""
return self.codes_file
@gid.setter
def gid(self, val):
self.codes_id = val
@grib_file.setter
def grib_file(self, val):
self.codes_file = val

View File

@ -1,7 +0,0 @@
# Use SWIG version 3.0.12
# Python3 support added with -py3
#
swig : gribapi_swig.i
swig -v -py3 -python -module gribapi_swig -o swig_wrap_numpy.c gribapi_swig.i
cp gribapi_swig.py swig_wrap_numpy.py

View File

@ -1,143 +0,0 @@
/* This part is automatically generated by ./errors.pl, do not edit */
#ifndef grib_errors_H
#define grib_errors_H
/*! \defgroup errors Error codes
Error codes returned by the grib_api functions.
*/
/*! @{*/
/** No error */
#define GRIB_SUCCESS 0
/** End of resource reached */
#define GRIB_END_OF_FILE -1
/** Internal error */
#define GRIB_INTERNAL_ERROR -2
/** Passed buffer is too small */
#define GRIB_BUFFER_TOO_SMALL -3
/** Function not yet implemented */
#define GRIB_NOT_IMPLEMENTED -4
/** Missing 7777 at end of message */
#define GRIB_7777_NOT_FOUND -5
/** Passed array is too small */
#define GRIB_ARRAY_TOO_SMALL -6
/** File not found */
#define GRIB_FILE_NOT_FOUND -7
/** Code not found in code table */
#define GRIB_CODE_NOT_FOUND_IN_TABLE -8
/** Array size mismatch */
#define GRIB_WRONG_ARRAY_SIZE -9
/** Key/value not found */
#define GRIB_NOT_FOUND -10
/** Input output problem */
#define GRIB_IO_PROBLEM -11
/** Message invalid */
#define GRIB_INVALID_MESSAGE -12
/** Decoding invalid */
#define GRIB_DECODING_ERROR -13
/** Encoding invalid */
#define GRIB_ENCODING_ERROR -14
/** Code cannot unpack because of string too small */
#define GRIB_NO_MORE_IN_SET -15
/** Problem with calculation of geographic attributes */
#define GRIB_GEOCALCULUS_PROBLEM -16
/** Memory allocation error */
#define GRIB_OUT_OF_MEMORY -17
/** Value is read only */
#define GRIB_READ_ONLY -18
/** Invalid argument */
#define GRIB_INVALID_ARGUMENT -19
/** Null handle */
#define GRIB_NULL_HANDLE -20
/** Invalid section number */
#define GRIB_INVALID_SECTION_NUMBER -21
/** Value cannot be missing */
#define GRIB_VALUE_CANNOT_BE_MISSING -22
/** Wrong message length */
#define GRIB_WRONG_LENGTH -23
/** Invalid key type */
#define GRIB_INVALID_TYPE -24
/** Unable to set step */
#define GRIB_WRONG_STEP -25
/** Wrong units for step (step must be integer) */
#define GRIB_WRONG_STEP_UNIT -26
/** Invalid file id */
#define GRIB_INVALID_FILE -27
/** Invalid grib id */
#define GRIB_INVALID_GRIB -28
/** Invalid index id */
#define GRIB_INVALID_INDEX -29
/** Invalid iterator id */
#define GRIB_INVALID_ITERATOR -30
/** Invalid keys iterator id */
#define GRIB_INVALID_KEYS_ITERATOR -31
/** Invalid nearest id */
#define GRIB_INVALID_NEAREST -32
/** Invalid order by */
#define GRIB_INVALID_ORDERBY -33
/** Missing a key from the fieldset */
#define GRIB_MISSING_KEY -34
/** The point is out of the grid area */
#define GRIB_OUT_OF_AREA -35
/** Concept no match */
#define GRIB_CONCEPT_NO_MATCH -36
/** Hash array no match */
#define GRIB_HASH_ARRAY_NO_MATCH -37
/** Definitions files not found */
#define GRIB_NO_DEFINITIONS -38
/** Wrong type while packing */
#define GRIB_WRONG_TYPE -39
/** End of resource */
#define GRIB_END -40
/** Unable to code a field without values */
#define GRIB_NO_VALUES -41
/** Grid description is wrong or inconsistent */
#define GRIB_WRONG_GRID -42
/** End of index reached */
#define GRIB_END_OF_INDEX -43
/** Null index */
#define GRIB_NULL_INDEX -44
/** End of resource reached when reading message */
#define GRIB_PREMATURE_END_OF_FILE -45
/** An internal array is too small */
#define GRIB_INTERNAL_ARRAY_TOO_SMALL -46
/** Message is too large for the current architecture */
#define GRIB_MESSAGE_TOO_LARGE -47
/** Constant field */
#define GRIB_CONSTANT_FIELD -48
/** Switch unable to find a matching case */
#define GRIB_SWITCH_NO_MATCH -49
/** Underflow */
#define GRIB_UNDERFLOW -50
/** Message malformed */
#define GRIB_MESSAGE_MALFORMED -51
/** Index is corrupted */
#define GRIB_CORRUPTED_INDEX -52
/** Invalid number of bits per value */
#define GRIB_INVALID_BPV -53
/** Edition of two messages is different */
#define GRIB_DIFFERENT_EDITION -54
/** Value is different */
#define GRIB_VALUE_DIFFERENT -55
/** Invalid key value */
#define GRIB_INVALID_KEY_VALUE -56
/** String is smaller than requested */
#define GRIB_STRING_TOO_SMALL -57
/** Wrong type conversion */
#define GRIB_WRONG_CONVERSION -58
/** Missing BUFR table entry for descriptor */
#define GRIB_MISSING_BUFR_ENTRY -59
/** Null pointer */
#define GRIB_NULL_POINTER -60
/** Attribute is already present, cannot add */
#define GRIB_ATTRIBUTE_CLASH -61
/** Too many attributes. Increase MAX_ACCESSOR_ATTRIBUTES */
#define GRIB_TOO_MANY_ATTRIBUTES -62
/** Attribute not found. */
#define GRIB_ATTRIBUTE_NOT_FOUND -63
/** Edition not supported. */
#define GRIB_UNSUPPORTED_EDITION -64
/** Value out of coding range */
#define GRIB_OUT_OF_RANGE -65
/** Size of bitmap is incorrect */
#define GRIB_WRONG_BITMAP_SIZE -66
/*! @}*/
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,126 +0,0 @@
#ifndef GRIB_INTERFACE_H
#define GRIB_INTERFACE_H
int grib_c_read_any_from_file(int *fid, char *buffer, int *nbytes);
int grib_c_write_file(int *fid, char *buffer, size_t *nbytes);
int grib_c_read_file(int *fid, char *buffer, size_t *nbytes);
int grib_c_open_file(int *fid, char *name, char *op);
int grib_c_close_file(int *fid);
int grib_c_multi_support_on(void);
int grib_c_multi_support_off(void);
int grib_c_iterator_new(int *gid, int *iterid, int *mode);
int grib_c_iterator_next(int *iterid, double *lat, double *lon, double *value);
int grib_c_iterator_delete(int *iterid);
int grib_c_keys_iterator_new(int *gid, int *iterid, char *name_space);
int grib_c_keys_iterator_next(int *iterid);
int grib_c_keys_iterator_get_name(int *iterid, char *name, int len);
int grib_c_keys_iterator_rewind(int *kiter);
int grib_c_keys_iterator_delete(int *iterid);
int codes_c_bufr_keys_iterator_new(int *gid, int *iterid);
int codes_c_bufr_keys_iterator_next(int *iterid);
int codes_c_bufr_keys_iterator_get_name(int *iterid, char *name, int len);
int codes_c_bufr_keys_iterator_rewind(int *kiter);
int codes_c_bufr_keys_iterator_delete(int *iterid);
int grib_c_gribex_mode_on(void);
int grib_c_gribex_mode_off(void);
int grib_c_skip_computed(int *iterid);
int grib_c_skip_coded(int *iterid);
int grib_c_skip_edition_specific(int *iterid);
int grib_c_skip_duplicates(int *iterid);
int grib_c_skip_read_only(int *iterid);
int grib_c_skip_function(int *iterid);
int grib_c_new_from_message(int *gid, void *buffer, size_t *bufsize);
int grib_c_new_from_message_copy(int *gid, void *buffer, size_t *bufsize);
int grib_c_grib_new_from_samples(int *gid, char *name);
int grib_c_bufr_new_from_samples(int *gid, char *name);
int grib_c_clone(int *gidsrc, int *giddest);
int grib_c_copy_namespace(int *gidsrc, char *name, int *giddest);
int grib_c_count_in_file(FILE *f, int *n);
int codes_c_close_file(int fd, char* fname);
int grib_c_new_from_file(FILE *f, int fd, char* fname, int *gid, int headers_only);
int grib_c_new_any_from_file(FILE *f, int fd, char* fname, int headers_only,int *gid);
int grib_c_new_bufr_from_file(FILE *f, int fd, char* fname, int headers_only,int *gid);
int grib_c_new_gts_from_file(FILE *f, int fd, char* fname, int headers_only, int *gid);
int grib_c_new_metar_from_file(FILE* f,int headers_only, int* gid);
int grib_c_new_from_index(int *iid, int *gid);
int grib_c_index_new_from_file(char *file, char *keys, int *gid);
int grib_c_index_add_file(int* iid, char* file);
int grib_c_index_release(int *hid);
int grib_c_multi_release(int *hid);
int grib_c_release(int *hid);
int grib_c_dump(int *gid);
int grib_c_print(int *gid, char *key);
int grib_c_get_error_string(int *err, char *buf, int len);
int grib_c_get_size_int(int *gid, char *key, int *val);
int grib_c_get_size_long(int *gid, char *key, long *val);
int grib_c_index_get_size_int(int *gid, char *key, int *val);
int grib_c_index_get_size_long(int *gid, char *key, long *val);
int grib_c_get_int(int *gid, char *key, int *val);
int grib_c_get_long(int *gid, char *key, long *val);
int grib_c_get_double(int *gid, char *key, double *val);
int grib_c_get_int_array(int *gid, char *key, int *val, size_t *size);
int grib_c_get_long_array(int *gid, char *key, long *val, int *size);
int grib_c_index_get_string(int *gid, char *key, char *val, int *eachsize, int *size);
int grib_c_index_get_long(int *gid, char *key, long *val, int *size);
int grib_c_index_get_int(int *gid, char *key, int *val, int *size);
int grib_c_index_get_real8(int *gid, char *key, double *val, int *size);
int grib_c_set_int_array(int *gid, char *key, int *val, size_t *size);
int grib_c_set_long_array(int *gid, char *key, long *val, int *size);
int grib_c_set_int(int *gid, char *key, int *val);
int grib_c_set_long(int *gid, char *key, long *val);
int grib_c_set_missing(int *gid, char *key);
int grib_c_set_key_vals(int* gid, char* keyvals);
int grib_c_is_missing(int *gid, char *key, int *isMissing);
int grib_c_is_defined(int *gid, char *key, int *isDefined);
int grib_c_set_real4(int *gid, char *key, float *val);
int grib_c_get_real4_element(int *gid, char *key, int *index, float *val);
int grib_c_get_real4_elements(int *gid, char *key, int *index, float *val, int *size);
int grib_c_get_real4(int *gid, char *key, float *val);
int grib_c_get_real4_array(int *gid, char *key, float *val, size_t *size);
int grib_c_set_real4_array(int *gid, char *key, float *val, int *size);
int grib_c_index_select_real8(int *gid, char *key, double *val);
int grib_c_index_select_string(int *gid, char *key, char *val);
int grib_c_index_select_int(int *gid, char *key, int *val);
int grib_c_index_select_long(int *gid, char *key, long *val);
int grib_c_set_real8(int *gid, char *key, double *val);
int grib_c_get_real8(int *gid, char *key, double *val);
int grib_c_get_real8_element(int *gid, char *key, int *index, double *val);
int grib_c_get_real8_elements(int *gid, char *key, int *index, double *val, int *size);
int grib_c_find_nearest_four_single(int *gid, int *is_lsm, double *inlat, double *inlon, double *outlats, double *outlons, double *values, double *distances, int *indexes);
int grib_c_find_nearest_single(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes);
int grib_c_find_nearest_multiple(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes, int *npoints);
int grib_c_get_real8_array(int *gid, char *key, double *val, int *size);
int grib_c_set_real8_array(int *gid, char *key, double *val, int *size);
int grib_c_get_string(int *gid, char *key, char *val, size_t *lsize);
int grib_c_get_string_array(int* gid, char* key, char** val, size_t *lsize);
int grib_c_set_string(int *gid, char *key, char *val, int len2);
int grib_c_set_string_array(int *gid, char *key, const char **val);
int grib_c_get_data_real4(int *gid, float *lats, float *lons, float *values, size_t *size);
/*int grib_c_get_data_real8(int *gid, double *lats, double *lons, double *values, size_t *size);*/
int grib_c_get_message_size(int *gid, size_t *len);
int grib_c_get_message_offset(int *gid, size_t *len);
int grib_c_copy_message(int *gid, void *mess, size_t *len);
int grib_c_bufr_copy_data(int *msgid_src, int *msgid_dst);
void grib_c_check(int *err, char *call, char *str);
int grib_c_write(int *gid, FILE *f);
int grib_c_multi_new(int* mgid);
int grib_c_multi_write(int *gid, FILE *f);
int grib_c_multi_append(int *ingid, int *sec, int *mgid);
int grib_c_set_double_array(int* gid, char* key, double*val, int* size);
int grib_c_set_double(int* gid, char* key, double*val);
int grib_c_get_native_type(int* gid, char* key, int* type);
int grib_c_index_write(int* gid, char* file);
int grib_c_index_read(char* file, int* gid);
void no_fail_on_wrong_length(int flag);
long grib_c_get_api_version(void);
void grib_c_gts_header_on(void);
void grib_c_gts_header_off(void);
int grib_c_get_message(int *gid, const void **msg, size_t *size);
int grib_c_get_string_length(int* gid, char* key, size_t* val);
void grib_c_set_definitions_path(const char* path);
void grib_c_set_samples_path(const char* path);
#endif

View File

@ -1,196 +0,0 @@
/*
* (C) Copyright 2005- ECMWF.
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
*
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
#include "Python.h"
#include "grib_api.h"
static PyObject* Error;
PyDoc_STRVAR(gribapi__doc__,
"gribapi point evalutation kernel");
PyDoc_STRVAR(read__doc__,
"gribapi point evalutation kernel");
static PyObject *
py_new_handle_from_file(PyObject *self, PyObject *args)
{
/* TODO: Call PyFile_Check or PyFile_CheckExact */
int err = 0;
grib_handle *h;
PyObject *file;
if(!PyArg_ParseTuple(args,"O",&file))
return NULL;
h = grib_handle_new_from_file(NULL,PyFile_AsFile(file),&err);
if(err) {
/* http://www.ragestorm.net/tutorial?id=21 */
PyErr_Format(Error,"grib_api: %s",grib_get_error_message(err));
return NULL;
}
/* TODO: Do an OO version */
if(h)
return PyLong_FromVoidPtr(h);
Py_RETURN_NONE;
}
static PyObject *
py_handle_delete(PyObject *self, PyObject *args)
{
PyObject* h;
if(!PyArg_ParseTuple(args,"O",&h))
return NULL;
grib_handle_delete(PyLong_AsVoidPtr(h));
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
py_keys_iterator_delete(PyObject *self, PyObject *args)
{
PyObject* h;
if(!PyArg_ParseTuple(args,"O",&h))
return NULL;
grib_keys_iterator_delete(PyLong_AsVoidPtr(h));
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
py_get_string(PyObject *self, PyObject *args)
{
PyObject* h;
char *s;
size_t size;
char tmp[1024];
int err;
if(!PyArg_ParseTuple(args,"Os",&h,&s))
return NULL;
size = sizeof(tmp);
err = grib_get_string(PyLong_AsVoidPtr(h),s,tmp,&size);
if(err) {
/* http://www.ragestorm.net/tutorial?id=21 */
PyErr_Format(Error,"grib_api: %s %s",s,grib_get_error_message(err));
return NULL;
}
return PyString_InternFromString(tmp);
}
static PyObject *
py_keys_iterator_next(PyObject *self, PyObject *args)
{
PyObject* h;
int more;
if(!PyArg_ParseTuple(args,"O",&h))
return NULL;
more = grib_keys_iterator_next(PyLong_AsVoidPtr(h));
if(more)
{
Py_RETURN_TRUE;
}
else
{
Py_RETURN_FALSE;
}
}
static PyObject *
py_keys_iterator_get_string(PyObject *self, PyObject *args)
{
PyObject* h;
size_t size;
char tmp[1024];
int err;
if(!PyArg_ParseTuple(args,"O",&h))
return NULL;
size = sizeof(tmp);
err = grib_keys_iterator_get_string(PyLong_AsVoidPtr(h),tmp,&size);
if(err) {
/* http://www.ragestorm.net/tutorial?id=21 */
PyErr_Format(Error,"grib_api: %s",grib_get_error_message(err));
return NULL;
}
return PyString_InternFromString(tmp);
}
static PyObject *
py_keys_iterator_get_name(PyObject *self, PyObject *args)
{
PyObject* h;
if(!PyArg_ParseTuple(args,"O",&h))
return NULL;
return PyString_InternFromString(grib_keys_iterator_get_name(PyLong_AsVoidPtr(h)));
}
static PyObject *
py_keys_iterator_new(PyObject *self, PyObject *args)
{
PyObject* h;
char *s;
if(!PyArg_ParseTuple(args,"Os",&h,&s))
return NULL;
return PyLong_FromVoidPtr(grib_keys_iterator_new(PyLong_AsVoidPtr(h),GRIB_KEYS_ITERATOR_ALL_KEYS,s));
}
static PyMethodDef gribapi_methods[] = {
{"new_handle_from_file", py_new_handle_from_file, METH_VARARGS, read__doc__},
{"get_string", py_get_string, METH_VARARGS, read__doc__},
{"keys_iterator_new", py_keys_iterator_new, METH_VARARGS, read__doc__},
{"keys_iterator_delete", py_keys_iterator_delete, METH_VARARGS, read__doc__},
{"handle_delete", py_handle_delete, METH_VARARGS, read__doc__},
{"keys_iterator_get_string", py_keys_iterator_get_string, METH_VARARGS, read__doc__},
{"keys_iterator_get_name", py_keys_iterator_get_name, METH_VARARGS, read__doc__},
{"keys_iterator_next", py_keys_iterator_next, METH_VARARGS, read__doc__},
{NULL, NULL} /* sentinel */
};
PyMODINIT_FUNC
initgribapi(void)
{
PyObject* m;
/* There have been several InitModule functions over time */
m = Py_InitModule3("gribapi", gribapi_methods, gribapi__doc__);
/* TODO: Create our own exception */
Error = PyErr_NewException("grib.apierror",NULL,NULL);
Py_INCREF(Error);
PyModule_AddObject(m, "error", Error);
}

View File

@ -1,2 +0,0 @@
from .gribapi import * # noqa
from .gribapi import __version__

View File

@ -1,235 +0,0 @@
"""
Exception class hierarchy
"""
from . import gribapi_swig as _internal
class GribInternalError(Exception):
"""
@brief Wrap errors coming from the C API in a Python exception object.
Base class for all exceptions
"""
def __init__(self, value):
# Call the base class constructor with the parameters it needs
Exception.__init__(self, value)
if type(value) is int:
err, self.msg = _internal.grib_c_get_error_string(value, 1024)
assert err == 0
else:
self.msg = value
def __str__(self):
return self.msg
class WrongBitmapSizeError(GribInternalError):
"""Size of bitmap is incorrect."""
class OutOfRangeError(GribInternalError):
"""Value out of coding range."""
class UnsupportedEditionError(GribInternalError):
"""Edition not supported.."""
class AttributeNotFoundError(GribInternalError):
"""Attribute not found.."""
class TooManyAttributesError(GribInternalError):
"""Too many attributes. Increase MAX_ACCESSOR_ATTRIBUTES."""
class AttributeClashError(GribInternalError):
"""Attribute is already present, cannot add."""
class NullPointerError(GribInternalError):
"""Null pointer."""
class MissingBufrEntryError(GribInternalError):
"""Missing BUFR table entry for descriptor."""
class WrongConversionError(GribInternalError):
"""Wrong type conversion."""
class StringTooSmallError(GribInternalError):
"""String is smaller than requested."""
class InvalidKeyValueError(GribInternalError):
"""Invalid key value."""
class ValueDifferentError(GribInternalError):
"""Value is different."""
class DifferentEditionError(GribInternalError):
"""Edition of two messages is different."""
class InvalidBitsPerValueError(GribInternalError):
"""Invalid number of bits per value."""
class CorruptedIndexError(GribInternalError):
"""Index is corrupted."""
class MessageMalformedError(GribInternalError):
"""Message malformed."""
class UnderflowError(GribInternalError):
"""Underflow."""
class SwitchNoMatchError(GribInternalError):
"""Switch unable to find a matching case."""
class ConstantFieldError(GribInternalError):
"""Constant field."""
class MessageTooLargeError(GribInternalError):
"""Message is too large for the current architecture."""
class InternalArrayTooSmallError(GribInternalError):
"""An internal array is too small."""
class PrematureEndOfFileError(GribInternalError):
"""End of resource reached when reading message."""
class NullIndexError(GribInternalError):
"""Null index."""
class EndOfIndexError(GribInternalError):
"""End of index reached."""
class WrongGridError(GribInternalError):
"""Grid description is wrong or inconsistent."""
class NoValuesError(GribInternalError):
"""Unable to code a field without values."""
class EndError(GribInternalError):
"""End of resource."""
class WrongTypeError(GribInternalError):
"""Wrong type while packing."""
class NoDefinitionsError(GribInternalError):
"""Definitions files not found."""
class HashArrayNoMatchError(GribInternalError):
"""Hash array no match."""
class ConceptNoMatchError(GribInternalError):
"""Concept no match."""
class OutOfAreaError(GribInternalError):
"""The point is out of the grid area."""
class MissingKeyError(GribInternalError):
"""Missing a key from the fieldset."""
class InvalidOrderByError(GribInternalError):
"""Invalid order by."""
class InvalidNearestError(GribInternalError):
"""Invalid nearest id."""
class InvalidKeysIteratorError(GribInternalError):
"""Invalid keys iterator id."""
class InvalidIteratorError(GribInternalError):
"""Invalid iterator id."""
class InvalidIndexError(GribInternalError):
"""Invalid index id."""
class InvalidGribError(GribInternalError):
"""Invalid grib id."""
class InvalidFileError(GribInternalError):
"""Invalid file id."""
class WrongStepUnitError(GribInternalError):
"""Wrong units for step (step must be integer)."""
class WrongStepError(GribInternalError):
"""Unable to set step."""
class InvalidTypeError(GribInternalError):
"""Invalid key type."""
class WrongLengthError(GribInternalError):
"""Wrong message length."""
class ValueCannotBeMissingError(GribInternalError):
"""Value cannot be missing."""
class InvalidSectionNumberError(GribInternalError):
"""Invalid section number."""
class NullHandleError(GribInternalError):
"""Null handle."""
class InvalidArgumentError(GribInternalError):
"""Invalid argument."""
class ReadOnlyError(GribInternalError):
"""Value is read only."""
class MemoryAllocationError(GribInternalError):
"""Memory allocation error."""
class GeocalculusError(GribInternalError):
"""Problem with calculation of geographic attributes."""
class NoMoreInSetError(GribInternalError):
"""Code cannot unpack because of string too small."""
class EncodingError(GribInternalError):
"""Encoding invalid."""
class DecodingError(GribInternalError):
"""Decoding invalid."""
class MessageInvalidError(GribInternalError):
"""Message invalid."""
class IOProblemError(GribInternalError):
"""Input output problem."""
class KeyValueNotFoundError(GribInternalError):
"""Key/value not found."""
class WrongArraySizeError(GribInternalError):
"""Array size mismatch."""
class CodeNotFoundInTableError(GribInternalError):
"""Code not found in code table."""
class FileNotFoundError(GribInternalError):
"""File not found."""
class ArrayTooSmallError(GribInternalError):
"""Passed array is too small."""
class MessageEndNotFoundError(GribInternalError):
"""Missing 7777 at end of message."""
class FunctionNotImplementedError(GribInternalError):
"""Function not yet implemented."""
class BufferTooSmallError(GribInternalError):
"""Passed buffer is too small."""
class InternalError(GribInternalError):
"""Internal error."""
class EndOfFileError(GribInternalError):
"""End of resource reached."""
ERROR_MAP = {
-66 : WrongBitmapSizeError,
-65 : OutOfRangeError,
-64 : UnsupportedEditionError,
-63 : AttributeNotFoundError,
-62 : TooManyAttributesError,
-61 : AttributeClashError,
-60 : NullPointerError,
-59 : MissingBufrEntryError,
-58 : WrongConversionError,
-57 : StringTooSmallError,
-56 : InvalidKeyValueError,
-55 : ValueDifferentError,
-54 : DifferentEditionError,
-53 : InvalidBitsPerValueError,
-52 : CorruptedIndexError,
-51 : MessageMalformedError,
-50 : UnderflowError,
-49 : SwitchNoMatchError,
-48 : ConstantFieldError,
-47 : MessageTooLargeError,
-46 : InternalArrayTooSmallError,
-45 : PrematureEndOfFileError,
-44 : NullIndexError,
-43 : EndOfIndexError,
-42 : WrongGridError,
-41 : NoValuesError,
-40 : EndError,
-39 : WrongTypeError,
-38 : NoDefinitionsError,
-37 : HashArrayNoMatchError,
-36 : ConceptNoMatchError,
-35 : OutOfAreaError,
-34 : MissingKeyError,
-33 : InvalidOrderByError,
-32 : InvalidNearestError,
-31 : InvalidKeysIteratorError,
-30 : InvalidIteratorError,
-29 : InvalidIndexError,
-28 : InvalidGribError,
-27 : InvalidFileError,
-26 : WrongStepUnitError,
-25 : WrongStepError,
-24 : InvalidTypeError,
-23 : WrongLengthError,
-22 : ValueCannotBeMissingError,
-21 : InvalidSectionNumberError,
-20 : NullHandleError,
-19 : InvalidArgumentError,
-18 : ReadOnlyError,
-17 : MemoryAllocationError,
-16 : GeocalculusError,
-15 : NoMoreInSetError,
-14 : EncodingError,
-13 : DecodingError,
-12 : MessageInvalidError,
-11 : IOProblemError,
-10 : KeyValueNotFoundError,
-9 : WrongArraySizeError,
-8 : CodeNotFoundInTableError,
-7 : FileNotFoundError,
-6 : ArrayTooSmallError,
-5 : MessageEndNotFoundError,
-4 : FunctionNotImplementedError,
-3 : BufferTooSmallError,
-2 : InternalError,
-1 : EndOfFileError
}
def raise_grib_error(errid):
"""
Raise the GribInternalError corresponding to ``errid``.
"""
raise ERROR_MAP[errid](errid)

File diff suppressed because it is too large Load Diff

View File

@ -1,266 +0,0 @@
%module gribapi_swig
%include "cpointer.i"
%include "cstring.i"
%include "typemaps.i"
%include "cdata.i"
%include "carrays.i"
%include "grib_errors.h"
%{
#define SWIG_FILE_WITH_INIT
#include "grib_interface.h"
%}
%include "numpy.i"
%init %{
import_array();
%}
/* Converts a PyFile instance to a stdio FILE* for reading binary files */
%typemap(in) FILE* {
int fileDescriptor = PyObject_AsFileDescriptor($input);
/*printf("swig.i fileDescriptor=%d\n", fileDescriptor);*/
if(fileDescriptor >= 0) {
/* Convert file descriptor to a FILE pointer */
$1 = fdopen(fileDescriptor,"rb"); // needs to be rb+ (or wb) for write
}
else {
PyErr_SetString(PyExc_TypeError, "$1_name must be a file type.");
return NULL;
}
}
%pointer_class(int, intp);
%pointer_class(size_t, sizetp);
%pointer_class(long, longp);
%pointer_class(double, doublep);
%array_functions(double, doubleArray);
%array_functions(long, longArray);
%array_functions(int, intArray);
%array_functions(char*, stringArray);
// creation
int grib_c_new_from_file(FILE* f, int fd, char* fname, int* INOUT, int headers_only);
int grib_c_new_any_from_file(FILE* f, int fd, char* fname, int headers_only, int* INOUT);
int grib_c_new_bufr_from_file(FILE* f, int fd, char* fname, int headers_only, int* INOUT);
int grib_c_new_gts_from_file(FILE* f, int fd, char* fname, int headers_only, int* INOUT);
int grib_c_new_metar_from_file(FILE* f, int headers_only, int* INOUT);
int grib_c_iterator_new(int* INPUT, int* OUTPUT, int* INPUT);
int grib_c_keys_iterator_new(int* INPUT, int* OUTPUT, char* name_space);
int codes_c_bufr_keys_iterator_new(int* INPUT, int* OUTPUT);
int grib_c_grib_new_from_samples(int* INOUT, char* name);
int grib_c_bufr_new_from_samples(int* INOUT, char* name);
int grib_c_index_new_from_file(char* file, char* keys, int* OUTPUT);
int grib_c_index_add_file(int* INPUT, char* file);
int grib_c_new_from_index(int *INPUT, int *INOUT);
int grib_c_index_write(int* INPUT, char* file);
int grib_c_index_read(char* file, int* OUTPUT);
int grib_c_new_from_message(int *INOUT, char *binmsg, size_t *INPUT);
// ---
%apply int* INPUT { int* fid };
%apply int* INPUT { int* gid };
%apply int* INPUT { int* iterid };
%apply int* INPUT { int* iid };
// file operations
int codes_c_close_file(int fd, char* fname);
int grib_c_count_in_file(FILE* f,int* OUTPUT);
// ---
/* Converts a PyFile instance to a stdio FILE* for writing binary files */
%typemap(in) FILE* {
int fileDescriptor = PyObject_AsFileDescriptor($input);
if(fileDescriptor >= 0) {
/* Convert file descriptor to a FILE pointer */
$1 = fdopen(fileDescriptor,"wb");
}
else {
PyErr_SetString(PyExc_TypeError, "$1_name must be a file type.");
return NULL;
}
}
// grib handle operations
int grib_c_release(int* gid);
int grib_c_write(int* gid, FILE* f);
int grib_c_get_size_long(int* gid, char* key, long* OUTPUT);
int grib_c_get_string_length(int* gid, char* key, size_t* OUTPUT);
int grib_c_clone(int* gid,int* INOUT);
int grib_c_copy_namespace(int* gid, char* name, int* INPUT);
int grib_c_get_message_size(int* gid, size_t* OUTPUT);
int grib_c_get_message_offset(int* gid, size_t* OUTPUT);
int grib_c_get_native_type(int* gid, char* key, int* OUTPUT);
// ---
// multi support
int grib_c_multi_new(int* OUTPUT);
int grib_c_multi_support_on(void);
int grib_c_multi_write(int* gid, FILE* f);
int grib_c_multi_support_off(void);
int grib_c_multi_release(int* gid);
int grib_c_multi_append(int* INPUT, int* INPUT,int* INPUT);
// ---
// gribex support
int grib_c_gribex_mode_on(void);
int grib_c_gribex_mode_off(void);
// ---
// keys iterator
int grib_c_keys_iterator_next(int* iterid);
int codes_c_bufr_keys_iterator_next(int* iterid);
int grib_c_keys_iterator_delete(int* iterid);
int codes_c_bufr_keys_iterator_delete(int* iterid);
int grib_c_skip_computed(int* iterid);
int grib_c_skip_coded(int* iterid);
int grib_c_skip_edition_specific(int* iterid);
int grib_c_skip_duplicates(int* iterid);
int grib_c_skip_read_only(int* iterid);
int grib_c_skip_function(int* iterid);
int grib_c_keys_iterator_rewind(int* iterid);
int codes_c_bufr_keys_iterator_rewind(int* iterid);
int grib_c_bufr_copy_data(int* gid, int* INOUT);
%cstring_bounded_output(char* name, 1024);
int grib_c_keys_iterator_get_name(int* iterid, char* name, int len);
int codes_c_bufr_keys_iterator_get_name(int* iterid, char* name, int len);
// ---
// indexing routines
int grib_c_index_get_size_long(int* iid, char* key, long* OUTPUT);
int grib_c_index_get_long(int* iid, char* key, long* val, int* size);
int grib_c_index_get_real8(int* iid, char* key, double* val, int* size);
%cstring_bounded_output(char* index_string_output, 1024*1024);
int grib_c_index_get_string(int* iid, char* key, char* index_string_output, int* INPUT, int* INOUT);
int grib_c_index_select_long(int *iid, char *key, long *INPUT);
int grib_c_index_select_real8(int *iid, char *key, double *INPUT);
int grib_c_index_select_string(int *iid, char *key, char *val);
int grib_c_index_release(int* iid);
// ---
// values iterator
int grib_c_iterator_delete(int* iterid);
int grib_c_iterator_next(int* iterid, double* OUTPUT, double* OUTPUT, double* OUTPUT);
// ---
// getting/setting key values
%cstring_output_withsize(char* string_val, size_t* string_size)
int grib_c_get_string(int* gid, char* key, char* string_val, size_t* string_size);
int grib_c_get_string_array(int* gid, char* key, char** array_string_val, size_t* size);
int grib_c_set_string(int* gid, char* key, char* sval, int len2);
int grib_c_get_long(int* gid, char* key, long* OUTPUT);
int grib_c_set_long(int* gid, char* key, long* INPUT);
int grib_c_get_double(int* gid, char* key, double* OUTPUT);
int grib_c_set_double(int* gid, char* key, double* INPUT);
int grib_c_set_real8_array(int* gid, char* key, double* val, int* size);
int grib_c_get_real8_array(int* gid, char* key, double* val, int* size);
int grib_c_get_long_array(int* gid, char* key, long* val, int* size);
int grib_c_set_long_array(int* gid, char* key, long* val, int* size);
int grib_c_get_real8_element(int* gid, char* key, int* INPUT, double* OUTPUT);
int grib_c_get_real8_elements(int* gid, char* key, int* index, double* val, int* size);
int grib_c_set_missing(int* gid, char* key);
int grib_c_set_key_vals(int* gid, char* keyvals);
int grib_c_is_missing(int* gid, char* key, int* OUTPUT);
int grib_c_is_defined(int* gid, char* key, int* OUTPUT);
// http://www.swig.org/Doc1.3/Python.html
// This tells SWIG to treat char ** as a special case
%typemap(in) char ** {
/* Check if is a list */
if (PyList_Check($input)) {
int size = PyList_Size($input);
int i = 0;
$1 = (char **) malloc((size+1)*sizeof(char *));
for (i = 0; i < size; i++) {
PyObject *o = PyList_GetItem($input,i);
if (PyString_Check(o))
$1[i] = PyString_AsString(PyList_GetItem($input,i));
else {
PyErr_SetString(PyExc_TypeError,"list must contain strings");
free($1);
return NULL;
}
}
$1[i] = 0; /* Last entry set to NULL */
} else {
PyErr_SetString(PyExc_TypeError,"not a list");
return NULL;
}
}
// This cleans up the char ** array we malloc'd before the function call
%typemap(freearg) char ** {
free((char *) $1);
}
int grib_c_set_string_array(int *gid, char *key, const char** val);
// Numpy Support
%apply (double* IN_ARRAY1, int DIM1) {(double* dpin_val, int dpin_val_dim1)};
%apply (long* IN_ARRAY1, int DIM1) {(long* lpin_val, int lpin_val_dim1)};
%apply (int* IN_ARRAY1, int DIM1) {(int* ipin_index, int ipin_index_dim1)};
%apply (double* ARGOUT_ARRAY1, int DIM1) {(double* dpout_val, int dpout_val_dim1)};
%apply (long* ARGOUT_ARRAY1, int DIM1) {(long* lpout_val, int lpout_val_dim1)};
%inline %{
//void with_numpy() {
// return;
//}
int grib_set_double_ndarray(int* gid, char* key, double* dpin_val, int dpin_val_dim1) {
return grib_c_set_real8_array(gid,key,dpin_val,&dpin_val_dim1);
}
int grib_set_long_ndarray(int* gid, char* key, long* lpin_val, int lpin_val_dim1) {
return grib_c_set_long_array(gid,key,lpin_val,&lpin_val_dim1);
}
int grib_get_double_ndarray(int* gid, char* key, double* dpout_val, int dpout_val_dim1) {
return grib_c_get_real8_array(gid,key,dpout_val,&dpout_val_dim1);
}
int grib_get_long_ndarray(int* gid, char* key, long* lpout_val, int lpout_val_dim1) {
return grib_c_get_long_array(gid,key,lpout_val,&lpout_val_dim1);
}
int grib_get_double_ndelements(int* gid, char* key, int* ipin_index, int ipin_index_dim1, double* dpout_val, int dpout_val_dim1) {
return grib_c_get_real8_elements(gid,key,ipin_index,dpout_val,&dpout_val_dim1);
}
%}
%clear double* dpin_val, int dpin_val_dim1;
%clear long* lpin_val, int lpin_val_dim1;
%clear int* ipout_val, int ipout_val_dim1;
%clear double* dpout_val, int dpout_val_dim1;
%clear long* lpout_val, int lpout_val_dim1;
// ---
// nearest
int grib_c_find_nearest_single(int* gid, int* INPUT, double* INPUT, double* INPUT, double* OUTPUT, double* OUTPUT, double* OUTPUT, double* OUTPUT, int* OUTPUT);
int grib_c_find_nearest_four_single(int* gid, int* INPUT, double* INPUT, double* INPUT, double* outlats, double* outlons, double* values, double* distances, int* indexes);
// ---
/*
* Get the binary string message for a grib.
*
* Set the 3rd argument to nothing in 'cstring_output_allocate_size'.
* This is kind of difficult to explain, but, *msg will point directly to
* the binary message data of the current grib (which is stored in
* handle->buffer->data if I remember correctly) so freeing it will cause
* the binary message data in the grib_handle structure to be freed. This
* is a problem as grib_api does not know that, so it tries to free it
* itself (grib_release does that) resulting in a 'Segmentation fault'.
*/
%cstring_output_allocate_size(const void **binmsg, size_t *binmsglen,);
int grib_c_get_message(int *gid, const void **binmsg, size_t *binmsglen);
%clear const void **binmsg, size_t *binmsglen;
%clear int* fid;
%clear int* gid;
%clear int* iterid;
%cstring_bounded_output(char* error_message, 1024);
int grib_c_get_error_string(int* INPUT, char* error_message, int len);
void no_fail_on_wrong_length(int flag);
long grib_c_get_api_version();
void grib_c_gts_header_on();
void grib_c_gts_header_off();
void grib_c_set_definitions_path(const char* path);
void grib_c_set_samples_path(const char* path);

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +0,0 @@
#!/bin/sh
input=$1
./test_general.py $input
./test_index.py $input
./test_keysiterator.py $input
./test_iterator.py $input

View File

@ -1,77 +0,0 @@
#!/usr/bin/env python
from distutils.core import setup, Extension
import os
import sys
import numpy
# Obtain the numpy include directory. This logic works across numpy versions.
try:
numpy_include = numpy.get_include()
except AttributeError:
numpy_include = numpy.get_numpy_include()
# See ECC-644
extra_compile_args = []
cmake_c_compiler_id='@CMAKE_C_COMPILER_ID@'
if cmake_c_compiler_id == 'PGI':
extra_compile_args.append('-noswitcherror')
attdict = dict(sources=['@CMAKE_CURRENT_SOURCE_DIR@/swig_wrap_numpy.c',
'@CMAKE_CURRENT_SOURCE_DIR@/grib_interface.c'],
swig_opts=[],
include_dirs=['.', '@CMAKE_CURRENT_BINARY_DIR@/../src',
'@CMAKE_CURRENT_SOURCE_DIR@/../src',
numpy_include],
library_dirs=['@CMAKE_BINARY_DIR@/lib'],
runtime_library_dirs=[],
libraries=['eccodes'],
extra_compile_args=extra_compile_args,
extra_objects=[])
shared_libs='@BUILD_SHARED_LIBS@'
if shared_libs == 'OFF':
add_attribute = lambda **args: [list.append(attdict[key], value)
for key, value in args.items()]
if @HAVE_LIBJASPER@:
jasper_dir = '@JASPER_DIR@'
if jasper_dir and jasper_dir != 'system':
add_attribute(library_dirs=os.path.join(jasper_dir, 'lib'),
runtime_library_dirs=os.path.join(jasper_dir, 'lib'))
add_attribute(libraries='jasper')
if @HAVE_LIBOPENJPEG@:
openjpeg_lib_dir = '@OPENJPEG_LIB_DIR@'
openjpeg_libname = '@OJ_WITHOUT_LIB@'
if openjpeg_lib_dir:
add_attribute(library_dirs=openjpeg_lib_dir,
runtime_library_dirs=openjpeg_lib_dir)
add_attribute(libraries=openjpeg_libname)
# assumes png is supplied by system paths -- may not be true
if @HAVE_LIBPNG@:
add_attribute(libraries='png')
if @HAVE_MEMFS@:
add_attribute(libraries='eccodes_memfs')
if @HAVE_AEC@:
aec_dir = '@AEC_DIR@'
if aec_dir and aec_dir != 'system':
add_attribute(library_dirs=os.path.join(aec_dir, 'lib'),
runtime_library_dirs=os.path.join(aec_dir, 'lib'))
add_attribute(libraries='aec')
setup(name='eccodes',
version='@ECCODES_VERSION_STR@',
author='ECMWF',
author_email='Software.Support@ecmwf.int',
description="""Python 3 interface for ecCodes""",
license='Apache License, Version 2.0',
url='https://confluence.ecmwf.int/display/ECC/ecCodes+Home',
download_url='https://confluence.ecmwf.int/display/ECC/Releases',
ext_modules=[Extension('gribapi._gribapi_swig', **attdict)],
packages=['eccodes', 'eccodes.high_level', 'gribapi'])

File diff suppressed because it is too large Load Diff

View File

@ -1,751 +0,0 @@
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.12
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info as _swig_python_version_info
if _swig_python_version_info >= (2, 7, 0):
def swig_import_helper():
import importlib
pkg = __name__.rpartition('.')[0]
mname = '.'.join((pkg, '_gribapi_swig')).lstrip('.')
try:
return importlib.import_module(mname)
except ImportError:
return importlib.import_module('_gribapi_swig')
_gribapi_swig = swig_import_helper()
del swig_import_helper
elif _swig_python_version_info >= (2, 6, 0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_gribapi_swig', [dirname(__file__)])
except ImportError:
import _gribapi_swig
return _gribapi_swig
try:
_mod = imp.load_module('_gribapi_swig', fp, pathname, description)
finally:
if fp is not None:
fp.close()
return _mod
_gribapi_swig = swig_import_helper()
del swig_import_helper
else:
import _gribapi_swig
del _swig_python_version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
try:
import builtins as __builtin__
except ImportError:
import __builtin__
def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
if (name == "thisown"):
return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name, None)
if method:
return method(self, value)
if (not static):
if _newclass:
object.__setattr__(self, name, value)
else:
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self, class_type, name, value):
return _swig_setattr_nondynamic(self, class_type, name, value, 0)
def _swig_getattr(self, class_type, name):
if (name == "thisown"):
return self.this.own()
method = class_type.__swig_getmethods__.get(name, None)
if method:
return method(self)
raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except __builtin__.Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try:
_object = object
_newclass = 1
except __builtin__.Exception:
class _object:
pass
_newclass = 0
def cdata(ptr: 'void *', nelements: 'size_t'=1) -> "SWIGCDATA":
return _gribapi_swig.cdata(ptr, nelements)
cdata = _gribapi_swig.cdata
def memmove(data: 'void *', indata: 'void const *') -> "void":
return _gribapi_swig.memmove(data, indata)
memmove = _gribapi_swig.memmove
GRIB_SUCCESS = _gribapi_swig.GRIB_SUCCESS
GRIB_END_OF_FILE = _gribapi_swig.GRIB_END_OF_FILE
GRIB_INTERNAL_ERROR = _gribapi_swig.GRIB_INTERNAL_ERROR
GRIB_BUFFER_TOO_SMALL = _gribapi_swig.GRIB_BUFFER_TOO_SMALL
GRIB_NOT_IMPLEMENTED = _gribapi_swig.GRIB_NOT_IMPLEMENTED
GRIB_7777_NOT_FOUND = _gribapi_swig.GRIB_7777_NOT_FOUND
GRIB_ARRAY_TOO_SMALL = _gribapi_swig.GRIB_ARRAY_TOO_SMALL
GRIB_FILE_NOT_FOUND = _gribapi_swig.GRIB_FILE_NOT_FOUND
GRIB_CODE_NOT_FOUND_IN_TABLE = _gribapi_swig.GRIB_CODE_NOT_FOUND_IN_TABLE
GRIB_WRONG_ARRAY_SIZE = _gribapi_swig.GRIB_WRONG_ARRAY_SIZE
GRIB_NOT_FOUND = _gribapi_swig.GRIB_NOT_FOUND
GRIB_IO_PROBLEM = _gribapi_swig.GRIB_IO_PROBLEM
GRIB_INVALID_MESSAGE = _gribapi_swig.GRIB_INVALID_MESSAGE
GRIB_DECODING_ERROR = _gribapi_swig.GRIB_DECODING_ERROR
GRIB_ENCODING_ERROR = _gribapi_swig.GRIB_ENCODING_ERROR
GRIB_NO_MORE_IN_SET = _gribapi_swig.GRIB_NO_MORE_IN_SET
GRIB_GEOCALCULUS_PROBLEM = _gribapi_swig.GRIB_GEOCALCULUS_PROBLEM
GRIB_OUT_OF_MEMORY = _gribapi_swig.GRIB_OUT_OF_MEMORY
GRIB_READ_ONLY = _gribapi_swig.GRIB_READ_ONLY
GRIB_INVALID_ARGUMENT = _gribapi_swig.GRIB_INVALID_ARGUMENT
GRIB_NULL_HANDLE = _gribapi_swig.GRIB_NULL_HANDLE
GRIB_INVALID_SECTION_NUMBER = _gribapi_swig.GRIB_INVALID_SECTION_NUMBER
GRIB_VALUE_CANNOT_BE_MISSING = _gribapi_swig.GRIB_VALUE_CANNOT_BE_MISSING
GRIB_WRONG_LENGTH = _gribapi_swig.GRIB_WRONG_LENGTH
GRIB_INVALID_TYPE = _gribapi_swig.GRIB_INVALID_TYPE
GRIB_WRONG_STEP = _gribapi_swig.GRIB_WRONG_STEP
GRIB_WRONG_STEP_UNIT = _gribapi_swig.GRIB_WRONG_STEP_UNIT
GRIB_INVALID_FILE = _gribapi_swig.GRIB_INVALID_FILE
GRIB_INVALID_GRIB = _gribapi_swig.GRIB_INVALID_GRIB
GRIB_INVALID_INDEX = _gribapi_swig.GRIB_INVALID_INDEX
GRIB_INVALID_ITERATOR = _gribapi_swig.GRIB_INVALID_ITERATOR
GRIB_INVALID_KEYS_ITERATOR = _gribapi_swig.GRIB_INVALID_KEYS_ITERATOR
GRIB_INVALID_NEAREST = _gribapi_swig.GRIB_INVALID_NEAREST
GRIB_INVALID_ORDERBY = _gribapi_swig.GRIB_INVALID_ORDERBY
GRIB_MISSING_KEY = _gribapi_swig.GRIB_MISSING_KEY
GRIB_OUT_OF_AREA = _gribapi_swig.GRIB_OUT_OF_AREA
GRIB_CONCEPT_NO_MATCH = _gribapi_swig.GRIB_CONCEPT_NO_MATCH
GRIB_HASH_ARRAY_NO_MATCH = _gribapi_swig.GRIB_HASH_ARRAY_NO_MATCH
GRIB_NO_DEFINITIONS = _gribapi_swig.GRIB_NO_DEFINITIONS
GRIB_WRONG_TYPE = _gribapi_swig.GRIB_WRONG_TYPE
GRIB_END = _gribapi_swig.GRIB_END
GRIB_NO_VALUES = _gribapi_swig.GRIB_NO_VALUES
GRIB_WRONG_GRID = _gribapi_swig.GRIB_WRONG_GRID
GRIB_END_OF_INDEX = _gribapi_swig.GRIB_END_OF_INDEX
GRIB_NULL_INDEX = _gribapi_swig.GRIB_NULL_INDEX
GRIB_PREMATURE_END_OF_FILE = _gribapi_swig.GRIB_PREMATURE_END_OF_FILE
GRIB_INTERNAL_ARRAY_TOO_SMALL = _gribapi_swig.GRIB_INTERNAL_ARRAY_TOO_SMALL
GRIB_MESSAGE_TOO_LARGE = _gribapi_swig.GRIB_MESSAGE_TOO_LARGE
GRIB_CONSTANT_FIELD = _gribapi_swig.GRIB_CONSTANT_FIELD
GRIB_SWITCH_NO_MATCH = _gribapi_swig.GRIB_SWITCH_NO_MATCH
GRIB_UNDERFLOW = _gribapi_swig.GRIB_UNDERFLOW
GRIB_MESSAGE_MALFORMED = _gribapi_swig.GRIB_MESSAGE_MALFORMED
GRIB_CORRUPTED_INDEX = _gribapi_swig.GRIB_CORRUPTED_INDEX
GRIB_INVALID_BPV = _gribapi_swig.GRIB_INVALID_BPV
GRIB_DIFFERENT_EDITION = _gribapi_swig.GRIB_DIFFERENT_EDITION
GRIB_VALUE_DIFFERENT = _gribapi_swig.GRIB_VALUE_DIFFERENT
GRIB_INVALID_KEY_VALUE = _gribapi_swig.GRIB_INVALID_KEY_VALUE
GRIB_STRING_TOO_SMALL = _gribapi_swig.GRIB_STRING_TOO_SMALL
GRIB_WRONG_CONVERSION = _gribapi_swig.GRIB_WRONG_CONVERSION
GRIB_MISSING_BUFR_ENTRY = _gribapi_swig.GRIB_MISSING_BUFR_ENTRY
GRIB_NULL_POINTER = _gribapi_swig.GRIB_NULL_POINTER
GRIB_ATTRIBUTE_CLASH = _gribapi_swig.GRIB_ATTRIBUTE_CLASH
GRIB_TOO_MANY_ATTRIBUTES = _gribapi_swig.GRIB_TOO_MANY_ATTRIBUTES
GRIB_ATTRIBUTE_NOT_FOUND = _gribapi_swig.GRIB_ATTRIBUTE_NOT_FOUND
GRIB_UNSUPPORTED_EDITION = _gribapi_swig.GRIB_UNSUPPORTED_EDITION
GRIB_OUT_OF_RANGE = _gribapi_swig.GRIB_OUT_OF_RANGE
GRIB_WRONG_BITMAP_SIZE = _gribapi_swig.GRIB_WRONG_BITMAP_SIZE
class intp(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, intp, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, intp, name)
__repr__ = _swig_repr
def __init__(self):
this = _gribapi_swig.new_intp()
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
__swig_destroy__ = _gribapi_swig.delete_intp
__del__ = lambda self: None
def assign(self, value: 'int') -> "void":
return _gribapi_swig.intp_assign(self, value)
def value(self) -> "int":
return _gribapi_swig.intp_value(self)
def cast(self) -> "int *":
return _gribapi_swig.intp_cast(self)
if _newclass:
frompointer = staticmethod(_gribapi_swig.intp_frompointer)
else:
frompointer = _gribapi_swig.intp_frompointer
intp_swigregister = _gribapi_swig.intp_swigregister
intp_swigregister(intp)
def intp_frompointer(t: 'int *') -> "intp *":
return _gribapi_swig.intp_frompointer(t)
intp_frompointer = _gribapi_swig.intp_frompointer
class sizetp(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, sizetp, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, sizetp, name)
__repr__ = _swig_repr
def __init__(self):
this = _gribapi_swig.new_sizetp()
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
__swig_destroy__ = _gribapi_swig.delete_sizetp
__del__ = lambda self: None
def assign(self, value: 'size_t') -> "void":
return _gribapi_swig.sizetp_assign(self, value)
def value(self) -> "size_t":
return _gribapi_swig.sizetp_value(self)
def cast(self) -> "size_t *":
return _gribapi_swig.sizetp_cast(self)
if _newclass:
frompointer = staticmethod(_gribapi_swig.sizetp_frompointer)
else:
frompointer = _gribapi_swig.sizetp_frompointer
sizetp_swigregister = _gribapi_swig.sizetp_swigregister
sizetp_swigregister(sizetp)
def sizetp_frompointer(t: 'size_t *') -> "sizetp *":
return _gribapi_swig.sizetp_frompointer(t)
sizetp_frompointer = _gribapi_swig.sizetp_frompointer
class longp(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, longp, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, longp, name)
__repr__ = _swig_repr
def __init__(self):
this = _gribapi_swig.new_longp()
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
__swig_destroy__ = _gribapi_swig.delete_longp
__del__ = lambda self: None
def assign(self, value: 'long') -> "void":
return _gribapi_swig.longp_assign(self, value)
def value(self) -> "long":
return _gribapi_swig.longp_value(self)
def cast(self) -> "long *":
return _gribapi_swig.longp_cast(self)
if _newclass:
frompointer = staticmethod(_gribapi_swig.longp_frompointer)
else:
frompointer = _gribapi_swig.longp_frompointer
longp_swigregister = _gribapi_swig.longp_swigregister
longp_swigregister(longp)
def longp_frompointer(t: 'long *') -> "longp *":
return _gribapi_swig.longp_frompointer(t)
longp_frompointer = _gribapi_swig.longp_frompointer
class doublep(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, doublep, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, doublep, name)
__repr__ = _swig_repr
def __init__(self):
this = _gribapi_swig.new_doublep()
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
__swig_destroy__ = _gribapi_swig.delete_doublep
__del__ = lambda self: None
def assign(self, value: 'double') -> "void":
return _gribapi_swig.doublep_assign(self, value)
def value(self) -> "double":
return _gribapi_swig.doublep_value(self)
def cast(self) -> "double *":
return _gribapi_swig.doublep_cast(self)
if _newclass:
frompointer = staticmethod(_gribapi_swig.doublep_frompointer)
else:
frompointer = _gribapi_swig.doublep_frompointer
doublep_swigregister = _gribapi_swig.doublep_swigregister
doublep_swigregister(doublep)
def doublep_frompointer(t: 'double *') -> "doublep *":
return _gribapi_swig.doublep_frompointer(t)
doublep_frompointer = _gribapi_swig.doublep_frompointer
def new_doubleArray(nelements: 'size_t') -> "double *":
return _gribapi_swig.new_doubleArray(nelements)
new_doubleArray = _gribapi_swig.new_doubleArray
def delete_doubleArray(ary: 'double *') -> "void":
return _gribapi_swig.delete_doubleArray(ary)
delete_doubleArray = _gribapi_swig.delete_doubleArray
def doubleArray_getitem(ary: 'double *', index: 'size_t') -> "double":
return _gribapi_swig.doubleArray_getitem(ary, index)
doubleArray_getitem = _gribapi_swig.doubleArray_getitem
def doubleArray_setitem(ary: 'double *', index: 'size_t', value: 'double') -> "void":
return _gribapi_swig.doubleArray_setitem(ary, index, value)
doubleArray_setitem = _gribapi_swig.doubleArray_setitem
def new_longArray(nelements: 'size_t') -> "long *":
return _gribapi_swig.new_longArray(nelements)
new_longArray = _gribapi_swig.new_longArray
def delete_longArray(ary: 'long *') -> "void":
return _gribapi_swig.delete_longArray(ary)
delete_longArray = _gribapi_swig.delete_longArray
def longArray_getitem(ary: 'long *', index: 'size_t') -> "long":
return _gribapi_swig.longArray_getitem(ary, index)
longArray_getitem = _gribapi_swig.longArray_getitem
def longArray_setitem(ary: 'long *', index: 'size_t', value: 'long') -> "void":
return _gribapi_swig.longArray_setitem(ary, index, value)
longArray_setitem = _gribapi_swig.longArray_setitem
def new_intArray(nelements: 'size_t') -> "int *":
return _gribapi_swig.new_intArray(nelements)
new_intArray = _gribapi_swig.new_intArray
def delete_intArray(ary: 'int *') -> "void":
return _gribapi_swig.delete_intArray(ary)
delete_intArray = _gribapi_swig.delete_intArray
def intArray_getitem(ary: 'int *', index: 'size_t') -> "int":
return _gribapi_swig.intArray_getitem(ary, index)
intArray_getitem = _gribapi_swig.intArray_getitem
def intArray_setitem(ary: 'int *', index: 'size_t', value: 'int') -> "void":
return _gribapi_swig.intArray_setitem(ary, index, value)
intArray_setitem = _gribapi_swig.intArray_setitem
def new_stringArray(nelements: 'size_t') -> "char **":
return _gribapi_swig.new_stringArray(nelements)
new_stringArray = _gribapi_swig.new_stringArray
def delete_stringArray(ary: 'char **') -> "void":
return _gribapi_swig.delete_stringArray(ary)
delete_stringArray = _gribapi_swig.delete_stringArray
def stringArray_getitem(ary: 'char **', index: 'size_t') -> "char *":
return _gribapi_swig.stringArray_getitem(ary, index)
stringArray_getitem = _gribapi_swig.stringArray_getitem
def stringArray_setitem(ary: 'char **', index: 'size_t', value: 'char *') -> "void":
return _gribapi_swig.stringArray_setitem(ary, index, value)
stringArray_setitem = _gribapi_swig.stringArray_setitem
def grib_c_new_from_file(f: 'FILE *', fd: 'int', fname: 'char *', INOUT: 'int *', headers_only: 'int') -> "int *":
return _gribapi_swig.grib_c_new_from_file(f, fd, fname, INOUT, headers_only)
grib_c_new_from_file = _gribapi_swig.grib_c_new_from_file
def grib_c_new_any_from_file(f: 'FILE *', fd: 'int', fname: 'char *', headers_only: 'int', INOUT: 'int *') -> "int *":
return _gribapi_swig.grib_c_new_any_from_file(f, fd, fname, headers_only, INOUT)
grib_c_new_any_from_file = _gribapi_swig.grib_c_new_any_from_file
def grib_c_new_bufr_from_file(f: 'FILE *', fd: 'int', fname: 'char *', headers_only: 'int', INOUT: 'int *') -> "int *":
return _gribapi_swig.grib_c_new_bufr_from_file(f, fd, fname, headers_only, INOUT)
grib_c_new_bufr_from_file = _gribapi_swig.grib_c_new_bufr_from_file
def grib_c_new_gts_from_file(f: 'FILE *', fd: 'int', fname: 'char *', headers_only: 'int', INOUT: 'int *') -> "int *":
return _gribapi_swig.grib_c_new_gts_from_file(f, fd, fname, headers_only, INOUT)
grib_c_new_gts_from_file = _gribapi_swig.grib_c_new_gts_from_file
def grib_c_new_metar_from_file(f: 'FILE *', headers_only: 'int', INOUT: 'int *') -> "int *":
return _gribapi_swig.grib_c_new_metar_from_file(f, headers_only, INOUT)
grib_c_new_metar_from_file = _gribapi_swig.grib_c_new_metar_from_file
def grib_c_iterator_new(arg1: 'int *', arg3: 'int *') -> "int *":
return _gribapi_swig.grib_c_iterator_new(arg1, arg3)
grib_c_iterator_new = _gribapi_swig.grib_c_iterator_new
def grib_c_keys_iterator_new(INPUT: 'int *', name_space: 'char *') -> "int *":
return _gribapi_swig.grib_c_keys_iterator_new(INPUT, name_space)
grib_c_keys_iterator_new = _gribapi_swig.grib_c_keys_iterator_new
def codes_c_bufr_keys_iterator_new(INPUT: 'int *') -> "int *":
return _gribapi_swig.codes_c_bufr_keys_iterator_new(INPUT)
codes_c_bufr_keys_iterator_new = _gribapi_swig.codes_c_bufr_keys_iterator_new
def grib_c_grib_new_from_samples(INOUT: 'int *', name: 'char *') -> "int *":
return _gribapi_swig.grib_c_grib_new_from_samples(INOUT, name)
grib_c_grib_new_from_samples = _gribapi_swig.grib_c_grib_new_from_samples
def grib_c_bufr_new_from_samples(INOUT: 'int *', name: 'char *') -> "int *":
return _gribapi_swig.grib_c_bufr_new_from_samples(INOUT, name)
grib_c_bufr_new_from_samples = _gribapi_swig.grib_c_bufr_new_from_samples
def grib_c_index_new_from_file(file: 'char *', keys: 'char *') -> "int *":
return _gribapi_swig.grib_c_index_new_from_file(file, keys)
grib_c_index_new_from_file = _gribapi_swig.grib_c_index_new_from_file
def grib_c_index_add_file(INPUT: 'int *', file: 'char *') -> "int":
return _gribapi_swig.grib_c_index_add_file(INPUT, file)
grib_c_index_add_file = _gribapi_swig.grib_c_index_add_file
def grib_c_new_from_index(INPUT: 'int *', INOUT: 'int *') -> "int *":
return _gribapi_swig.grib_c_new_from_index(INPUT, INOUT)
grib_c_new_from_index = _gribapi_swig.grib_c_new_from_index
def grib_c_index_write(INPUT: 'int *', file: 'char *') -> "int":
return _gribapi_swig.grib_c_index_write(INPUT, file)
grib_c_index_write = _gribapi_swig.grib_c_index_write
def grib_c_index_read(file: 'char *') -> "int *":
return _gribapi_swig.grib_c_index_read(file)
grib_c_index_read = _gribapi_swig.grib_c_index_read
def grib_c_new_from_message(INOUT: 'int *', binmsg: 'char *', INPUT: 'size_t *') -> "int *":
return _gribapi_swig.grib_c_new_from_message(INOUT, binmsg, INPUT)
grib_c_new_from_message = _gribapi_swig.grib_c_new_from_message
def codes_c_close_file(fd: 'int', fname: 'char *') -> "int":
return _gribapi_swig.codes_c_close_file(fd, fname)
codes_c_close_file = _gribapi_swig.codes_c_close_file
def grib_c_count_in_file(f: 'FILE *') -> "int *":
return _gribapi_swig.grib_c_count_in_file(f)
grib_c_count_in_file = _gribapi_swig.grib_c_count_in_file
def grib_c_release(gid: 'int *') -> "int":
return _gribapi_swig.grib_c_release(gid)
grib_c_release = _gribapi_swig.grib_c_release
def grib_c_write(gid: 'int *', f: 'FILE *') -> "int":
return _gribapi_swig.grib_c_write(gid, f)
grib_c_write = _gribapi_swig.grib_c_write
def grib_c_get_size_long(gid: 'int *', key: 'char *') -> "long *":
return _gribapi_swig.grib_c_get_size_long(gid, key)
grib_c_get_size_long = _gribapi_swig.grib_c_get_size_long
def grib_c_get_string_length(gid: 'int *', key: 'char *') -> "size_t *":
return _gribapi_swig.grib_c_get_string_length(gid, key)
grib_c_get_string_length = _gribapi_swig.grib_c_get_string_length
def grib_c_clone(gid: 'int *', INOUT: 'int *') -> "int *":
return _gribapi_swig.grib_c_clone(gid, INOUT)
grib_c_clone = _gribapi_swig.grib_c_clone
def grib_c_copy_namespace(gid: 'int *', name: 'char *', INPUT: 'int *') -> "int":
return _gribapi_swig.grib_c_copy_namespace(gid, name, INPUT)
grib_c_copy_namespace = _gribapi_swig.grib_c_copy_namespace
def grib_c_get_message_size(gid: 'int *') -> "size_t *":
return _gribapi_swig.grib_c_get_message_size(gid)
grib_c_get_message_size = _gribapi_swig.grib_c_get_message_size
def grib_c_get_message_offset(gid: 'int *') -> "size_t *":
return _gribapi_swig.grib_c_get_message_offset(gid)
grib_c_get_message_offset = _gribapi_swig.grib_c_get_message_offset
def grib_c_get_native_type(gid: 'int *', key: 'char *') -> "int *":
return _gribapi_swig.grib_c_get_native_type(gid, key)
grib_c_get_native_type = _gribapi_swig.grib_c_get_native_type
def grib_c_multi_new() -> "int *":
return _gribapi_swig.grib_c_multi_new()
grib_c_multi_new = _gribapi_swig.grib_c_multi_new
def grib_c_multi_support_on() -> "int":
return _gribapi_swig.grib_c_multi_support_on()
grib_c_multi_support_on = _gribapi_swig.grib_c_multi_support_on
def grib_c_multi_write(gid: 'int *', f: 'FILE *') -> "int":
return _gribapi_swig.grib_c_multi_write(gid, f)
grib_c_multi_write = _gribapi_swig.grib_c_multi_write
def grib_c_multi_support_off() -> "int":
return _gribapi_swig.grib_c_multi_support_off()
grib_c_multi_support_off = _gribapi_swig.grib_c_multi_support_off
def grib_c_multi_release(gid: 'int *') -> "int":
return _gribapi_swig.grib_c_multi_release(gid)
grib_c_multi_release = _gribapi_swig.grib_c_multi_release
def grib_c_multi_append(arg1: 'int *', arg2: 'int *', arg3: 'int *') -> "int":
return _gribapi_swig.grib_c_multi_append(arg1, arg2, arg3)
grib_c_multi_append = _gribapi_swig.grib_c_multi_append
def grib_c_gribex_mode_on() -> "int":
return _gribapi_swig.grib_c_gribex_mode_on()
grib_c_gribex_mode_on = _gribapi_swig.grib_c_gribex_mode_on
def grib_c_gribex_mode_off() -> "int":
return _gribapi_swig.grib_c_gribex_mode_off()
grib_c_gribex_mode_off = _gribapi_swig.grib_c_gribex_mode_off
def grib_c_keys_iterator_next(iterid: 'int *') -> "int":
return _gribapi_swig.grib_c_keys_iterator_next(iterid)
grib_c_keys_iterator_next = _gribapi_swig.grib_c_keys_iterator_next
def codes_c_bufr_keys_iterator_next(iterid: 'int *') -> "int":
return _gribapi_swig.codes_c_bufr_keys_iterator_next(iterid)
codes_c_bufr_keys_iterator_next = _gribapi_swig.codes_c_bufr_keys_iterator_next
def grib_c_keys_iterator_delete(iterid: 'int *') -> "int":
return _gribapi_swig.grib_c_keys_iterator_delete(iterid)
grib_c_keys_iterator_delete = _gribapi_swig.grib_c_keys_iterator_delete
def codes_c_bufr_keys_iterator_delete(iterid: 'int *') -> "int":
return _gribapi_swig.codes_c_bufr_keys_iterator_delete(iterid)
codes_c_bufr_keys_iterator_delete = _gribapi_swig.codes_c_bufr_keys_iterator_delete
def grib_c_skip_computed(iterid: 'int *') -> "int":
return _gribapi_swig.grib_c_skip_computed(iterid)
grib_c_skip_computed = _gribapi_swig.grib_c_skip_computed
def grib_c_skip_coded(iterid: 'int *') -> "int":
return _gribapi_swig.grib_c_skip_coded(iterid)
grib_c_skip_coded = _gribapi_swig.grib_c_skip_coded
def grib_c_skip_edition_specific(iterid: 'int *') -> "int":
return _gribapi_swig.grib_c_skip_edition_specific(iterid)
grib_c_skip_edition_specific = _gribapi_swig.grib_c_skip_edition_specific
def grib_c_skip_duplicates(iterid: 'int *') -> "int":
return _gribapi_swig.grib_c_skip_duplicates(iterid)
grib_c_skip_duplicates = _gribapi_swig.grib_c_skip_duplicates
def grib_c_skip_read_only(iterid: 'int *') -> "int":
return _gribapi_swig.grib_c_skip_read_only(iterid)
grib_c_skip_read_only = _gribapi_swig.grib_c_skip_read_only
def grib_c_skip_function(iterid: 'int *') -> "int":
return _gribapi_swig.grib_c_skip_function(iterid)
grib_c_skip_function = _gribapi_swig.grib_c_skip_function
def grib_c_keys_iterator_rewind(iterid: 'int *') -> "int":
return _gribapi_swig.grib_c_keys_iterator_rewind(iterid)
grib_c_keys_iterator_rewind = _gribapi_swig.grib_c_keys_iterator_rewind
def codes_c_bufr_keys_iterator_rewind(iterid: 'int *') -> "int":
return _gribapi_swig.codes_c_bufr_keys_iterator_rewind(iterid)
codes_c_bufr_keys_iterator_rewind = _gribapi_swig.codes_c_bufr_keys_iterator_rewind
def grib_c_bufr_copy_data(gid: 'int *', INOUT: 'int *') -> "int *":
return _gribapi_swig.grib_c_bufr_copy_data(gid, INOUT)
grib_c_bufr_copy_data = _gribapi_swig.grib_c_bufr_copy_data
def grib_c_keys_iterator_get_name(iterid: 'int *', len: 'int') -> "char *":
return _gribapi_swig.grib_c_keys_iterator_get_name(iterid, len)
grib_c_keys_iterator_get_name = _gribapi_swig.grib_c_keys_iterator_get_name
def codes_c_bufr_keys_iterator_get_name(iterid: 'int *', len: 'int') -> "char *":
return _gribapi_swig.codes_c_bufr_keys_iterator_get_name(iterid, len)
codes_c_bufr_keys_iterator_get_name = _gribapi_swig.codes_c_bufr_keys_iterator_get_name
def grib_c_index_get_size_long(iid: 'int *', key: 'char *') -> "long *":
return _gribapi_swig.grib_c_index_get_size_long(iid, key)
grib_c_index_get_size_long = _gribapi_swig.grib_c_index_get_size_long
def grib_c_index_get_long(iid: 'int *', key: 'char *', val: 'long *', size: 'int *') -> "int":
return _gribapi_swig.grib_c_index_get_long(iid, key, val, size)
grib_c_index_get_long = _gribapi_swig.grib_c_index_get_long
def grib_c_index_get_real8(iid: 'int *', key: 'char *', val: 'double *', size: 'int *') -> "int":
return _gribapi_swig.grib_c_index_get_real8(iid, key, val, size)
grib_c_index_get_real8 = _gribapi_swig.grib_c_index_get_real8
def grib_c_index_get_string(iid: 'int *', key: 'char *', INPUT: 'int *', INOUT: 'int *') -> "char *, int *":
return _gribapi_swig.grib_c_index_get_string(iid, key, INPUT, INOUT)
grib_c_index_get_string = _gribapi_swig.grib_c_index_get_string
def grib_c_index_select_long(iid: 'int *', key: 'char *', INPUT: 'long *') -> "int":
return _gribapi_swig.grib_c_index_select_long(iid, key, INPUT)
grib_c_index_select_long = _gribapi_swig.grib_c_index_select_long
def grib_c_index_select_real8(iid: 'int *', key: 'char *', INPUT: 'double *') -> "int":
return _gribapi_swig.grib_c_index_select_real8(iid, key, INPUT)
grib_c_index_select_real8 = _gribapi_swig.grib_c_index_select_real8
def grib_c_index_select_string(iid: 'int *', key: 'char *', val: 'char *') -> "int":
return _gribapi_swig.grib_c_index_select_string(iid, key, val)
grib_c_index_select_string = _gribapi_swig.grib_c_index_select_string
def grib_c_index_release(iid: 'int *') -> "int":
return _gribapi_swig.grib_c_index_release(iid)
grib_c_index_release = _gribapi_swig.grib_c_index_release
def grib_c_iterator_delete(iterid: 'int *') -> "int":
return _gribapi_swig.grib_c_iterator_delete(iterid)
grib_c_iterator_delete = _gribapi_swig.grib_c_iterator_delete
def grib_c_iterator_next(iterid: 'int *') -> "double *, double *, double *":
return _gribapi_swig.grib_c_iterator_next(iterid)
grib_c_iterator_next = _gribapi_swig.grib_c_iterator_next
def grib_c_get_string(gid: 'int *', key: 'char *', string_val: 'char *') -> "size_t *":
return _gribapi_swig.grib_c_get_string(gid, key, string_val)
grib_c_get_string = _gribapi_swig.grib_c_get_string
def grib_c_get_string_array(gid: 'int *', key: 'char *', array_string_val: 'char **', size: 'size_t *') -> "int":
return _gribapi_swig.grib_c_get_string_array(gid, key, array_string_val, size)
grib_c_get_string_array = _gribapi_swig.grib_c_get_string_array
def grib_c_set_string(gid: 'int *', key: 'char *', sval: 'char *', len2: 'int') -> "int":
return _gribapi_swig.grib_c_set_string(gid, key, sval, len2)
grib_c_set_string = _gribapi_swig.grib_c_set_string
def grib_c_get_long(gid: 'int *', key: 'char *') -> "long *":
return _gribapi_swig.grib_c_get_long(gid, key)
grib_c_get_long = _gribapi_swig.grib_c_get_long
def grib_c_set_long(gid: 'int *', key: 'char *', INPUT: 'long *') -> "int":
return _gribapi_swig.grib_c_set_long(gid, key, INPUT)
grib_c_set_long = _gribapi_swig.grib_c_set_long
def grib_c_get_double(gid: 'int *', key: 'char *') -> "double *":
return _gribapi_swig.grib_c_get_double(gid, key)
grib_c_get_double = _gribapi_swig.grib_c_get_double
def grib_c_set_double(gid: 'int *', key: 'char *', INPUT: 'double *') -> "int":
return _gribapi_swig.grib_c_set_double(gid, key, INPUT)
grib_c_set_double = _gribapi_swig.grib_c_set_double
def grib_c_set_real8_array(gid: 'int *', key: 'char *', val: 'double *', size: 'int *') -> "int":
return _gribapi_swig.grib_c_set_real8_array(gid, key, val, size)
grib_c_set_real8_array = _gribapi_swig.grib_c_set_real8_array
def grib_c_get_real8_array(gid: 'int *', key: 'char *', val: 'double *', size: 'int *') -> "int":
return _gribapi_swig.grib_c_get_real8_array(gid, key, val, size)
grib_c_get_real8_array = _gribapi_swig.grib_c_get_real8_array
def grib_c_get_long_array(gid: 'int *', key: 'char *', val: 'long *', size: 'int *') -> "int":
return _gribapi_swig.grib_c_get_long_array(gid, key, val, size)
grib_c_get_long_array = _gribapi_swig.grib_c_get_long_array
def grib_c_set_long_array(gid: 'int *', key: 'char *', val: 'long *', size: 'int *') -> "int":
return _gribapi_swig.grib_c_set_long_array(gid, key, val, size)
grib_c_set_long_array = _gribapi_swig.grib_c_set_long_array
def grib_c_get_real8_element(gid: 'int *', key: 'char *', INPUT: 'int *') -> "double *":
return _gribapi_swig.grib_c_get_real8_element(gid, key, INPUT)
grib_c_get_real8_element = _gribapi_swig.grib_c_get_real8_element
def grib_c_get_real8_elements(gid: 'int *', key: 'char *', index: 'int *', val: 'double *', size: 'int *') -> "int":
return _gribapi_swig.grib_c_get_real8_elements(gid, key, index, val, size)
grib_c_get_real8_elements = _gribapi_swig.grib_c_get_real8_elements
def grib_c_set_missing(gid: 'int *', key: 'char *') -> "int":
return _gribapi_swig.grib_c_set_missing(gid, key)
grib_c_set_missing = _gribapi_swig.grib_c_set_missing
def grib_c_set_key_vals(gid: 'int *', keyvals: 'char *') -> "int":
return _gribapi_swig.grib_c_set_key_vals(gid, keyvals)
grib_c_set_key_vals = _gribapi_swig.grib_c_set_key_vals
def grib_c_is_missing(gid: 'int *', key: 'char *') -> "int *":
return _gribapi_swig.grib_c_is_missing(gid, key)
grib_c_is_missing = _gribapi_swig.grib_c_is_missing
def grib_c_is_defined(gid: 'int *', key: 'char *') -> "int *":
return _gribapi_swig.grib_c_is_defined(gid, key)
grib_c_is_defined = _gribapi_swig.grib_c_is_defined
def grib_c_set_string_array(gid: 'int *', key: 'char *', val: 'char const **') -> "int":
return _gribapi_swig.grib_c_set_string_array(gid, key, val)
grib_c_set_string_array = _gribapi_swig.grib_c_set_string_array
def grib_set_double_ndarray(gid: 'int *', key: 'char *', dpin_val: 'double *') -> "int":
return _gribapi_swig.grib_set_double_ndarray(gid, key, dpin_val)
grib_set_double_ndarray = _gribapi_swig.grib_set_double_ndarray
def grib_set_long_ndarray(gid: 'int *', key: 'char *', lpin_val: 'long *') -> "int":
return _gribapi_swig.grib_set_long_ndarray(gid, key, lpin_val)
grib_set_long_ndarray = _gribapi_swig.grib_set_long_ndarray
def grib_get_double_ndarray(gid: 'int *', key: 'char *', dpout_val: 'double *') -> "int":
return _gribapi_swig.grib_get_double_ndarray(gid, key, dpout_val)
grib_get_double_ndarray = _gribapi_swig.grib_get_double_ndarray
def grib_get_long_ndarray(gid: 'int *', key: 'char *', lpout_val: 'long *') -> "int":
return _gribapi_swig.grib_get_long_ndarray(gid, key, lpout_val)
grib_get_long_ndarray = _gribapi_swig.grib_get_long_ndarray
def grib_get_double_ndelements(gid: 'int *', key: 'char *', ipin_index: 'int *', dpout_val: 'double *') -> "int":
return _gribapi_swig.grib_get_double_ndelements(gid, key, ipin_index, dpout_val)
grib_get_double_ndelements = _gribapi_swig.grib_get_double_ndelements
def grib_c_find_nearest_single(gid: 'int *', arg2: 'int *', arg3: 'double *', arg4: 'double *') -> "double *, double *, double *, double *, int *":
return _gribapi_swig.grib_c_find_nearest_single(gid, arg2, arg3, arg4)
grib_c_find_nearest_single = _gribapi_swig.grib_c_find_nearest_single
def grib_c_find_nearest_four_single(gid: 'int *', arg2: 'int *', arg3: 'double *', arg4: 'double *', outlats: 'double *', outlons: 'double *', values: 'double *', distances: 'double *', indexes: 'int *') -> "int":
return _gribapi_swig.grib_c_find_nearest_four_single(gid, arg2, arg3, arg4, outlats, outlons, values, distances, indexes)
grib_c_find_nearest_four_single = _gribapi_swig.grib_c_find_nearest_four_single
def grib_c_get_message(gid: 'int *') -> "size_t *":
return _gribapi_swig.grib_c_get_message(gid)
grib_c_get_message = _gribapi_swig.grib_c_get_message
def grib_c_get_error_string(INPUT: 'int *', len: 'int') -> "char *":
return _gribapi_swig.grib_c_get_error_string(INPUT, len)
grib_c_get_error_string = _gribapi_swig.grib_c_get_error_string
def no_fail_on_wrong_length(flag: 'int') -> "void":
return _gribapi_swig.no_fail_on_wrong_length(flag)
no_fail_on_wrong_length = _gribapi_swig.no_fail_on_wrong_length
def grib_c_get_api_version() -> "long":
return _gribapi_swig.grib_c_get_api_version()
grib_c_get_api_version = _gribapi_swig.grib_c_get_api_version
def grib_c_gts_header_on() -> "void":
return _gribapi_swig.grib_c_gts_header_on()
grib_c_gts_header_on = _gribapi_swig.grib_c_gts_header_on
def grib_c_gts_header_off() -> "void":
return _gribapi_swig.grib_c_gts_header_off()
grib_c_gts_header_off = _gribapi_swig.grib_c_gts_header_off
def grib_c_set_definitions_path(path: 'char const *') -> "void":
return _gribapi_swig.grib_c_set_definitions_path(path)
grib_c_set_definitions_path = _gribapi_swig.grib_c_set_definitions_path
def grib_c_set_samples_path(path: 'char const *') -> "void":
return _gribapi_swig.grib_c_set_samples_path(path)
grib_c_set_samples_path = _gribapi_swig.grib_c_set_samples_path
# This file is compatible with both classic and new-style classes.

View File

@ -1,42 +0,0 @@
#!/usr/bin/env python
import sys
from gribapi import *
import profile
def main():
infile = sys.argv[1]
fid = open(infile,"r")
count = grib_count_in_file(fid)
for i in range(count):
gid = grib_new_from_file(fid)
nval = grib_get_size(gid,"values")
iterid = grib_iterator_new(gid,0)
missingValue = grib_get_double(gid,"missingValue")
i=0
while 1:
result = grib_iterator_next(iterid)
if not result: break
[lat,lon,value] = result
sys.stdout.write("- %d - lat=%.6f lon=%.6f value=" % (i,lat,lon))
if value == missingValue:
print("missing")
else:
print("%.6f" % value)
i += 1
grib_iterator_delete(iterid)
grib_release(gid)
fid.close()
if __name__ == "__main__":
#profile.run('main()')
main()

View File

@ -184,6 +184,7 @@ list( APPEND grib_api_srcs
grib_accessor_class_spectral_truncation.c
grib_accessor_class_time.c
grib_accessor_class_transient.c
grib_accessor_class_trim.c
grib_accessor_class_transient_darray.c
grib_accessor_class_values.c
grib_accessor_class_simple_packing_error.c

View File

@ -201,6 +201,7 @@ libeccodes_la_prototypes= \
grib_accessor_class_spectral_truncation.c \
grib_accessor_class_time.c \
grib_accessor_class_transient.c \
grib_accessor_class_trim.c \
grib_accessor_class_values.c \
grib_accessor_class_simple_packing_error.c \
grib_accessor_class_data_simple_packing.c \

View File

@ -89,28 +89,12 @@ int codes_bufr_keys_iterator_rewind(bufr_keys_iterator* ki)
return GRIB_SUCCESS;
}
static int is_ident_key(const bufr_keys_iterator* kiter)
{
if (kiter->current->sub_section)
return 0;
if ((GRIB_ACCESSOR_FLAG_HIDDEN & kiter->current->flags) != 0 &&
strcmp(kiter->current->name, "keyMore") == 0 &&
grib_is_defined(kiter->handle, "ls.ident")) {
return 1;
}
return 0;
}
static int skip(bufr_keys_iterator* kiter)
{
if (kiter->current->sub_section)
return 1;
if (kiter->current->flags & kiter->accessor_flags_skip) {
/* The "ident" key deserves special treatment */
if (is_ident_key(kiter))
return 0;
return 1;
}
@ -233,12 +217,7 @@ char* codes_bufr_keys_iterator_get_name(const bufr_keys_iterator* ckiter)
sprintf(ret, "#%d#%s", *r, kiter->current->name);
}
else {
if (is_ident_key(kiter)) {
strcpy(ret, "ident");
}
else {
strcpy(ret, kiter->current->name);
}
strcpy(ret, kiter->current->name);
}
}

View File

@ -204,6 +204,8 @@ static int bufr_decode_rdb_keys(const void* message, long offset_section2, codes
return GRIB_SUCCESS;
}
#define IDENT_LEN 9 /* 8 chars plus the final 0 terminator */
/* The ECMWF BUFR local use section */
static int bufr_decode_extra_rdb_keys(const void* message, long offset_section2, codes_bufr_header* hdr)
{
@ -261,8 +263,11 @@ static int bufr_decode_extra_rdb_keys(const void* message, long offset_section2,
}
}
else {
size_t i = 0;
long lValue = 0;
size_t i = 0;
long lValue = 0;
char* pTemp = NULL;
char temp[IDENT_LEN] = {0,};
start = 72;
lValue = (long)grib_decode_unsigned_long(pKeyData, &start, 25);
hdr->localLatitude = (lValue - 9000000.0) / 100000.0;
@ -270,11 +275,14 @@ static int bufr_decode_extra_rdb_keys(const void* message, long offset_section2,
lValue = (long)grib_decode_unsigned_long(pKeyData, &start, 26);
hdr->localLongitude = (lValue - 18000000.0) / 100000.0;
/* interpret keyMore as a string */
for (i = 0; i < 8; ++i) {
hdr->ident[i] = *pKeyMore++;
/* interpret keyMore as a string. Copy to a temporary */
for (i = 0; i < IDENT_LEN - 1; ++i) {
temp[i] = *pKeyMore++;
}
hdr->ident[i] = '\0';
temp[i] = '\0';
pTemp = temp;
lrtrim(&pTemp, 1, 1); /* Trim left and right */
strncpy(hdr->ident, pTemp, IDENT_LEN - 1);
}
return GRIB_SUCCESS;

View File

@ -96,7 +96,7 @@ int codes_fieldset_count(grib_fieldset* set)
/* Indexing */
/******************************************************************************/
grib_index* codes_index_new_from_file(grib_context* c, char* filename, const char* keys, int* err)
grib_index* codes_index_new_from_file(grib_context* c, const char* filename, const char* keys, int* err)
{
return grib_index_new_from_file(c, filename, keys, err);
}
@ -140,7 +140,7 @@ int codes_index_select_double(grib_index* index, const char* key, double value)
{
return grib_index_select_double(index, key, value);
}
int codes_index_select_string(grib_index* index, const char* key, char* value)
int codes_index_select_string(grib_index* index, const char* key, const char* value)
{
return grib_index_select_string(index, key, value);
}

View File

@ -214,7 +214,7 @@ typedef struct grib_index codes_index;
* @param err : 0 if OK, integer value on error
* @return the newly created index
*/
codes_index* codes_index_new_from_file(codes_context* c, char* filename, const char* keys, int* err);
codes_index* codes_index_new_from_file(codes_context* c, const char* filename, const char* keys, int* err);
/**
* Create a new index based on a set of keys.
@ -320,7 +320,7 @@ int codes_index_select_double(codes_index* index, const char* key, double value)
* @param value : value of the key to select
* @return 0 if OK, integer value on error
*/
int codes_index_select_string(codes_index* index, const char* key, char* value);
int codes_index_select_string(codes_index* index, const char* key, const char* value);
/**
* Create a new handle from an index after having selected the key values.
@ -1253,6 +1253,7 @@ int codes_points_get_values(codes_handle* h, codes_points* points, double* val);
#define CODES_UTIL_PACKING_TYPE_GRID_SIMPLE_MATRIX GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE_MATRIX
#define CODES_UTIL_PACKING_TYPE_GRID_SECOND_ORDER GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER
#define CODES_UTIL_PACKING_TYPE_CCSDS GRIB_UTIL_PACKING_TYPE_CCSDS
#define CODES_UTIL_PACKING_TYPE_IEEE GRIB_UTIL_PACKING_TYPE_IEEE
#define CODES_UTIL_PACKING_SAME_AS_INPUT GRIB_UTIL_PACKING_SAME_AS_INPUT
#define CODES_UTIL_PACKING_USE_PROVIDED GRIB_UTIL_PACKING_USE_PROVIDED

View File

@ -208,6 +208,7 @@ extern grib_accessor_class* grib_accessor_class_to_integer;
extern grib_accessor_class* grib_accessor_class_to_string;
extern grib_accessor_class* grib_accessor_class_transient;
extern grib_accessor_class* grib_accessor_class_transient_darray;
extern grib_accessor_class* grib_accessor_class_trim;
extern grib_accessor_class* grib_accessor_class_uint16;
extern grib_accessor_class* grib_accessor_class_uint16_little_endian;
extern grib_accessor_class* grib_accessor_class_uint32;

View File

@ -313,6 +313,7 @@ static int select_area(grib_accessor* a)
if (nsubsets != 0) {
subsets_ar = grib_iarray_get_array(subsets);
ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets);
grib_context_free(c, subsets_ar);
if (ret)
return ret;

View File

@ -443,6 +443,7 @@ static int select_datetime(grib_accessor* a)
if (nsubsets != 0) {
subsets_ar = grib_iarray_get_array(subsets);
ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets);
grib_context_free(c, subsets_ar);
if (ret)
return ret;

View File

@ -207,6 +207,7 @@ static int apply_thinning(grib_accessor* a)
if (nsubsets != 0) {
subsets_ar = grib_iarray_get_array(subsets);
ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets);
grib_context_free(c, subsets_ar);
if (ret)
return ret;
@ -218,6 +219,7 @@ static int apply_thinning(grib_accessor* a)
if (ret)
return ret;
}
grib_iarray_delete(subsets);
}
else {
return GRIB_NOT_IMPLEMENTED;

View File

@ -265,11 +265,11 @@ static void __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, bufr_
*err = grib_get_size(hand, self->sequence, &size);
grib_bufr_descriptor_delete(u);
if (*err)
return;
goto cleanup;
v = (long*)grib_context_malloc_clear(c, sizeof(long) * size);
*err = grib_get_long_array(hand, self->sequence, v, &size);
if (*err)
return;
goto cleanup;
inner_unexpanded = grib_bufr_descriptors_array_new(c, DESC_SIZE_INIT, DESC_SIZE_INCR);
for (i = 0; i < size; i++) {
@ -518,8 +518,8 @@ static void __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, bufr_
printf("\t");
printf("expanding <== %d-%.2d-%.3d (size=%ld)\n\n", us->F, us->X, us->Y, size);
#endif
if (us)
grib_bufr_descriptor_delete(us);
cleanup:
if (us) grib_bufr_descriptor_delete(us);
}
static bufr_descriptors_array* do_expand(grib_accessor* a, bufr_descriptors_array* unexpanded, change_coding_params* ccp, int* err)
@ -552,8 +552,10 @@ static bufr_descriptors_array* do_expand(grib_accessor* a, bufr_descriptors_arra
#endif
while (unexpanded->n) {
__expand(a, unexpanded, expanded, ccp, err);
if (*err)
if (*err) {
grib_bufr_descriptors_array_delete(expanded);
return NULL;
}
}
#if MYDEBUG
{
@ -689,8 +691,11 @@ static int expand(grib_accessor* a)
ccp.associatedFieldWidth = 0;
ccp.newStringWidth = 0;
self->expanded = do_expand(a, unexpanded, &ccp, &err);
if (err)
if (err) {
grib_bufr_descriptors_array_delete(unexpanded);
grib_bufr_descriptors_array_delete(unexpanded_copy);
return err;
}
grib_context_expanded_descriptors_list_push(c, key, self->expanded, unexpanded_copy);
grib_bufr_descriptors_array_delete(unexpanded);
@ -809,6 +814,7 @@ static int value_count(grib_accessor* a, long* rlen)
err = expand(a);
if (err) {
grib_context_log(a->context, GRIB_LOG_ERROR, "%s unable to compute size", a->name);
grib_bufr_descriptors_array_delete(self->expanded);
return err;
}
*rlen = BUFR_DESCRIPTORS_ARRAY_USED_SIZE(self->expanded);

View File

@ -571,6 +571,13 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
if (err)
return 0;
if (*len < self->tableCodesSize) {
grib_context_log(a->context, GRIB_LOG_ERROR,
" wrong size (%ld) for %s it contains %d values ", *len, a->name, self->tableCodesSize);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
for (i = 0; i < self->tableCodesSize; i++)
val[i] = self->tableCodes[i];

View File

@ -0,0 +1,200 @@
/*
* (C) Copyright 2005- ECMWF.
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
*
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
#include "grib_api_internal.h"
/*
This is used by make_class.pl
START_CLASS_DEF
CLASS = accessor
SUPER = grib_accessor_class_ascii
IMPLEMENTS = unpack_string;pack_string
IMPLEMENTS = init; string_length
MEMBERS= const char* input
MEMBERS= int trim_left
MEMBERS= int trim_right
END_CLASS_DEF
*/
/* START_CLASS_IMP */
/*
Don't edit anything between START_CLASS_IMP and END_CLASS_IMP
Instead edit values between START_CLASS_DEF and END_CLASS_DEF
or edit "accessor.class" and rerun ./make_class.pl
*/
static int pack_string(grib_accessor*, const char*, size_t* len);
static int unpack_string(grib_accessor*, char*, size_t* len);
static size_t string_length(grib_accessor*);
static void init(grib_accessor*, const long, grib_arguments*);
static void init_class(grib_accessor_class*);
typedef struct grib_accessor_trim
{
grib_accessor att;
/* Members defined in gen */
/* Members defined in ascii */
/* Members defined in trim */
const char* input;
int trim_left;
int trim_right;
} grib_accessor_trim;
extern grib_accessor_class* grib_accessor_class_ascii;
static grib_accessor_class _grib_accessor_class_trim = {
&grib_accessor_class_ascii, /* super */
"trim", /* name */
sizeof(grib_accessor_trim), /* size */
0, /* inited */
&init_class, /* init_class */
&init, /* init */
0, /* post_init */
0, /* free mem */
0, /* describes himself */
0, /* get length of section */
&string_length, /* get length of string */
0, /* get number of values */
0, /* get number of bytes */
0, /* get offset to bytes */
0, /* get native type */
0, /* get sub_section */
0, /* grib_pack procedures long */
0, /* grib_pack procedures long */
0, /* grib_pack procedures long */
0, /* grib_unpack procedures long */
0, /* grib_pack procedures double */
0, /* grib_unpack procedures double */
&pack_string, /* grib_pack procedures string */
&unpack_string, /* grib_unpack procedures string */
0, /* grib_pack array procedures string */
0, /* grib_unpack array procedures string */
0, /* grib_pack procedures bytes */
0, /* grib_unpack procedures bytes */
0, /* pack_expression */
0, /* notify_change */
0, /* update_size */
0, /* preferred_size */
0, /* resize */
0, /* nearest_smaller_value */
0, /* next accessor */
0, /* compare vs. another accessor */
0, /* unpack only ith value */
0, /* unpack a subarray */
0, /* clear */
0, /* clone accessor */
};
grib_accessor_class* grib_accessor_class_trim = &_grib_accessor_class_trim;
static void init_class(grib_accessor_class* c)
{
c->dump = (*(c->super))->dump;
c->next_offset = (*(c->super))->next_offset;
c->value_count = (*(c->super))->value_count;
c->byte_count = (*(c->super))->byte_count;
c->byte_offset = (*(c->super))->byte_offset;
c->get_native_type = (*(c->super))->get_native_type;
c->sub_section = (*(c->super))->sub_section;
c->pack_missing = (*(c->super))->pack_missing;
c->is_missing = (*(c->super))->is_missing;
c->pack_long = (*(c->super))->pack_long;
c->unpack_long = (*(c->super))->unpack_long;
c->pack_double = (*(c->super))->pack_double;
c->unpack_double = (*(c->super))->unpack_double;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;
c->notify_change = (*(c->super))->notify_change;
c->update_size = (*(c->super))->update_size;
c->preferred_size = (*(c->super))->preferred_size;
c->resize = (*(c->super))->resize;
c->nearest_smaller_value = (*(c->super))->nearest_smaller_value;
c->next = (*(c->super))->next;
c->compare = (*(c->super))->compare;
c->unpack_double_element = (*(c->super))->unpack_double_element;
c->unpack_double_subarray = (*(c->super))->unpack_double_subarray;
c->clear = (*(c->super))->clear;
c->make_clone = (*(c->super))->make_clone;
}
/* END_CLASS_IMP */
static void init(grib_accessor* a, const long l, grib_arguments* arg)
{
int n = 0;
grib_accessor_trim* self = (grib_accessor_trim*)a;
grib_handle* h = grib_handle_of_accessor(a);
self->input = grib_arguments_get_name(h, arg, n++);
self->trim_left = grib_arguments_get_long(h, arg, n++);
self->trim_right= grib_arguments_get_long(h, arg, n++);
DebugAssert(self->trim_left == 0 || self->trim_left == 1);
DebugAssert(self->trim_right == 0 || self->trim_right == 1);
}
static int unpack_string(grib_accessor* a, char* val, size_t* len)
{
grib_accessor_trim* self = (grib_accessor_trim*)a;
int err = 0;
grib_handle* h = grib_handle_of_accessor(a);
char input[256] = {0,};
size_t size = sizeof(input) / sizeof(*input);
char* pInput = input;
err = grib_get_string(h, self->input, input, &size);
if (err) return err;
lrtrim(&pInput, self->trim_left, self->trim_right);
sprintf(val, "%s", pInput);
size = strlen(val);
*len = size + 1;
return GRIB_SUCCESS;
}
static int pack_string(grib_accessor* a, const char* val, size_t* len)
{
char input[256] = {0,};
size_t inputLen = 256;
char buf[256] = {0,};
char* pBuf = NULL;
int err;
grib_handle* h = grib_handle_of_accessor(a);
grib_accessor_trim* self = (grib_accessor_trim*)a;
grib_accessor* inputAccesstor = grib_find_accessor(h, self->input);
if (!inputAccesstor) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor for %s not found", self->input);
return GRIB_NOT_FOUND;
}
if ((err = grib_get_string(h, self->input, input, &inputLen)) != GRIB_SUCCESS)
return err;
sprintf(buf, "%s", val);
pBuf = buf;
lrtrim(&pBuf, self->trim_left, self->trim_right);
return grib_pack_string(inputAccesstor, pBuf, len);
}
static size_t string_length(grib_accessor* a)
{
return 1024;
}

File diff suppressed because it is too large Load Diff

View File

@ -207,6 +207,7 @@
{ "to_string", &grib_accessor_class_to_string, },
{ "transient", &grib_accessor_class_transient, },
{ "transient_darray", &grib_accessor_class_transient_darray, },
{ "trim", &grib_accessor_class_trim, },
{ "uint16", &grib_accessor_class_uint16, },
{ "uint16_little_endian", &grib_accessor_class_uint16_little_endian, },
{ "uint32", &grib_accessor_class_uint32, },

View File

@ -208,6 +208,7 @@ to_integer, &grib_accessor_class_to_integer
to_string, &grib_accessor_class_to_string
transient, &grib_accessor_class_transient
transient_darray, &grib_accessor_class_transient_darray
trim, &grib_accessor_class_trim
uint16, &grib_accessor_class_uint16
uint16_little_endian, &grib_accessor_class_uint16_little_endian
uint32, &grib_accessor_class_uint32

View File

@ -266,7 +266,7 @@ typedef struct grib_index grib_index;
* @return the newly created index
*/
grib_index* grib_index_new_from_file(grib_context* c,
char* filename, const char* keys, int* err);
const char* filename, const char* keys, int* err);
/**
* Create a new index based on a set of keys.
*
@ -374,7 +374,7 @@ int grib_index_select_double(grib_index* index, const char* key, double value);
* @param value : value of the key to select
* @return 0 if OK, integer value on error
*/
int grib_index_select_string(grib_index* index, const char* key, char* value);
int grib_index_select_string(grib_index* index, const char* key, const char* value);
/**
* Create a new handle from an index after having selected the key values.
@ -1522,6 +1522,7 @@ typedef struct grib_util_grid_spec2
#define GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE_MATRIX 6
#define GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER 7
#define GRIB_UTIL_PACKING_TYPE_CCSDS 8
#define GRIB_UTIL_PACKING_TYPE_IEEE 9
#define GRIB_UTIL_PACKING_SAME_AS_INPUT 0
#define GRIB_UTIL_PACKING_USE_PROVIDED 1

View File

@ -731,15 +731,14 @@ int grib_index_add_file(grib_index* index, const char* filename);
grib_handle* new_message_from_file(int message_type, grib_context* c, FILE* f, int* error);
int _codes_index_add_file(grib_index* index, const char* filename, int message_type);
int grib_index_add_file(grib_index* index, const char* filename);
grib_index* grib_index_new_from_file(grib_context* c, char* filename, const char* keys, int* err);
grib_index* grib_index_new_from_file(grib_context* c, const char* filename, const char* keys, int* err);
int grib_index_get_size(const grib_index* index, const char* key, size_t* size);
int grib_index_get_string(const grib_index* index, const char* key, char** values, size_t* size);
int grib_index_get_long(const grib_index* index, const char* key, long* values, size_t* size);
int grib_index_get_double(const grib_index* index, const char* key, double* values, size_t* size);
int grib_index_select_long(grib_index* index, const char* skey, long value);
int grib_index_select_double(grib_index* index, const char* skey, double value);
int grib_index_select_string(grib_index* index, const char* skey, char* value);
grib_handle* grib_index_get_handle(grib_field* field, int* err);
int grib_index_select_string(grib_index* index, const char* skey, const char* value);
grib_handle* codes_index_get_handle(grib_field* field, int message_type, int* err);
int grib_index_dump_file(FILE* fout, const char* filename);
void grib_index_dump(FILE* fout, grib_index* index);
@ -1048,6 +1047,8 @@ int grib_get_gaussian_latitudes(long trunc, double* lats);
int is_gaussian_global(double lat1, double lat2, double lon1, double lon2, long num_points_equator, const double* latitudes, double angular_precision);
void rotate(const double inlat, const double inlon, const double angleOfRot, const double southPoleLat, const double southPoleLon, double* outlat, double* outlon);
void unrotate(const double inlat, const double inlon, const double angleOfRot, const double southPoleLat, const double southPoleLon, double* outlat, double* outlon);
double geographic_distance_spherical(double radius, double lon1, double lat1, double lon2, double lat2);
double geographic_distance_ellipsoid(double major, double minor, double lon1, double lat1, double lon2, double lat2);
/* grib_handle.c */
grib_section* grib_section_create(grib_handle* h, grib_accessor* owner);
@ -1376,7 +1377,6 @@ int grib_nearest_find(grib_nearest* nearest, const grib_handle* h, double inlat,
int grib_nearest_init(grib_nearest* i, grib_handle* h, grib_arguments* args);
int grib_nearest_delete(grib_nearest* i);
void grib_binary_search(double xx[], const unsigned long n, double x, int* ju, int* jl);
double grib_nearest_distance(double radius, double lon1, double lat1, double lon2, double lat2);
int grib_nearest_find_multiple(const grib_handle* h, int is_lsm, const double* inlats, const double* inlons, long npoints, double* outlats, double* outlons, double* values, double* distances, int* indexes);
int grib_nearest_find_generic(grib_nearest* nearest, grib_handle* h, double inlat, double inlon, unsigned long flags,
const char* values_keyname, const char* radius_keyname,
@ -1493,6 +1493,7 @@ int codes_bufr_header_get_string(codes_bufr_header* bh, const char* key, char* v
/* string_util.c */
int strcmp_nocase(const char* s1, const char* s2);
void rtrim(char* s);
void lrtrim(char** x, int do_left, int do_right);
const char* extract_filename(const char* filepath);
char** string_split(char* inputString, const char* delimiter);
int string_to_long(const char* input, long* output);

View File

@ -30,6 +30,12 @@ long GRIB_MASK = -1; /* Mask of sword bits */
((b) == max_nbits ? GRIB_MASK : (~(GRIB_MASK << (b)) << (max_nbits - ((q) + (b)))))
#define VALUE_SIZE_T(p, q, b) \
(((b) == max_nbits_size_t ? GRIB_MASK : ~(GRIB_MASK << (b))) & ((p) >> (max_nbits_size_t - ((q) + (b)))))
#define MASKVALUE_SIZE_T(q, b) \
((b) == max_nbits_size_t ? GRIB_MASK : (~(GRIB_MASK << (b)) << (max_nbits_size_t - ((q) + (b)))))
static const unsigned long dmasks[] = {
0xFF,
0xFE,

View File

@ -10,16 +10,15 @@
/***************************************************************************
* Enrico Fucile - 19.06.2007 *
* *
* Johannes Schick, Deutscher Wetterdienst - 24.06.2020 *
***************************************************************************/
int grib_decode_long_array(const unsigned char* p, long* bitp, long bitsPerValue,
size_t n_vals, long* val)
{
long i = 0;
unsigned long lvalue = 0;
if (bitsPerValue % 8) {
if (bitsPerValue % 8 || (*bitp & 7)) {
int j = 0;
for (i = 0; i < n_vals; i++) {
lvalue = 0;
@ -113,15 +112,47 @@ int grib_encode_double_array(size_t n_vals, const double* val, long bits_per_val
}
}
else {
for (i = 0; i < n_vals; i++) {
int blen = 0;
blen = bits_per_value;
unsigned_val = (unsigned long)((((val[i] * d) - reference_value) * divisor) + 0.5);
while (blen >= 8) {
blen -= 8;
*encoded = (unsigned_val >> blen);
encoded++;
*off += 8;
if (bits_per_value == 16 && !((uint64_t)p & 3)) {
uint32_t* encoded4byte = (uint32_t*)p;
uint32_t tmp;
unsigned long unsigned_val2 = 0;
for (i = 0; i < n_vals - 1; i += 2) {
unsigned_val = (unsigned long)((((val[i] * d) - reference_value) * divisor) + 0.5);
unsigned_val2 = (unsigned long)((((val[i + 1] * d) - reference_value) * divisor) + 0.5);
tmp = (unsigned_val2 & 0xff);
tmp = (tmp << 8) + (unsigned_val2 >> 8 & 0xff);
tmp = (tmp << 8) + (unsigned_val & 0xff);
tmp = (tmp << 8) + ((unsigned_val >> 8) & 0xff);
*encoded4byte = tmp;
encoded4byte++;
*off += 32;
}
/* remainder */
if (n_vals % 2) {
int blen = 0;
i = n_vals - 1;
encoded = (unsigned char*)encoded4byte;
blen = bits_per_value;
unsigned_val = (unsigned long)((((val[i] * d) - reference_value) * divisor) + 0.5);
while (blen >= 8) {
blen -= 8;
*encoded = (unsigned_val >> blen);
encoded++;
*off += 8;
}
}
}
else {
for (i = 0; i < n_vals; i++) {
int blen = 0;
blen = bits_per_value;
unsigned_val = (unsigned long)((((val[i] * d) - reference_value) * divisor) + 0.5);
while (blen >= 8) {
blen -= 8;
*encoded = (unsigned_val >> blen);
encoded++;
*off += 8;
}
}
}
}

View File

@ -114,7 +114,6 @@ char* grib_decode_string(const unsigned char* bitStream, long* bitOffset, size_t
return string;
}
unsigned long grib_decode_unsigned_long(const unsigned char* p, long* bitp, long nbits)
{
long countOfLeftmostBits = 0, leftmostBits = 0;
@ -146,6 +145,37 @@ unsigned long grib_decode_unsigned_long(const unsigned char* p, long* bitp, long
return val;
}
size_t grib_decode_size_t(const unsigned char* p, long* bitp, long nbits)
{
long countOfLeftmostBits = 0, leftmostBits = 0;
long startBit = *bitp;
long remainingBits = nbits;
long* pp = (long*)p;
size_t val = 0;
if (startBit >= max_nbits_size_t) {
pp += startBit / max_nbits_size_t;
startBit %= max_nbits_size_t;
}
countOfLeftmostBits = startBit + remainingBits;
if (countOfLeftmostBits > max_nbits_size_t) {
countOfLeftmostBits = max_nbits_size_t - startBit;
remainingBits -= countOfLeftmostBits;
leftmostBits = (VALUE_SIZE_T(*pp, startBit, countOfLeftmostBits)) << remainingBits;
startBit = 0;
pp++;
}
else
leftmostBits = 0;
val = leftmostBits + (VALUE_SIZE_T(*pp, startBit, remainingBits));
*bitp += nbits;
return val;
}
int grib_encode_unsigned_long(unsigned char* p, unsigned long val, long* bitp, long nbits)
{
long* destination = (long*)p;
@ -185,8 +215,48 @@ int grib_encode_unsigned_longb(unsigned char* p, unsigned long val, long* bitp,
return grib_encode_unsigned_long(p, val, bitp, nbits);
}
int grib_encode_size_t(unsigned char* p, size_t val, long* bitp, long nbits)
{
long* destination = (long*)p;
long countOfLeftmostBits = 0, nextWord = 0, startBit = 0, remainingBits = 0, rightmostBits = 0;
startBit = *bitp;
remainingBits = nbits;
if (startBit >= max_nbits_size_t) {
nextWord = startBit / max_nbits_size_t;
startBit %= max_nbits_size_t;
}
else
nextWord = 0;
countOfLeftmostBits = startBit + remainingBits;
if (countOfLeftmostBits > max_nbits_size_t) {
countOfLeftmostBits = max_nbits_size_t - startBit;
startBit = max_nbits_size_t - remainingBits;
remainingBits -= countOfLeftmostBits;
destination[nextWord] =
((destination[nextWord] >> countOfLeftmostBits) << countOfLeftmostBits) + (VALUE_SIZE_T(val, startBit, countOfLeftmostBits));
startBit = 0;
nextWord++;
}
rightmostBits = VALUE_SIZE_T(val, max_nbits_size_t - remainingBits, remainingBits);
destination[nextWord] =
(destination[nextWord] & ~MASKVALUE_SIZE_T(startBit, remainingBits)) + (rightmostBits << max_nbits_size_t - (remainingBits + startBit));
*bitp += nbits;
return GRIB_SUCCESS;
}
int grib_encode_size_tb(unsigned char* p, size_t val, long* bitp, long nbits)
{
return grib_encode_size_t(p, val, bitp, nbits);
}
#if VECTOR
#include "grib_bits_fast_big_endian_vector.c"
#include "grib_bits_fast_big_endian_vector.c" /* Experimental */
#elif OMP
#include "grib_bits_fast_big_endian_omp.c"
#else

View File

@ -280,7 +280,7 @@ const char* grib_get_package_name()
return "ecCodes";
}
#define DEFAULT_FILE_POOL_MAX_OPENED_FILES 200
#define DEFAULT_FILE_POOL_MAX_OPENED_FILES 0
static grib_context default_grib_context = {
0, /* inited */
@ -425,19 +425,19 @@ grib_context* grib_context_get_default()
_set_fmode(_O_BINARY);
#endif
default_grib_context.inited = 1;
default_grib_context.io_buffer_size = io_buffer_size ? atoi(io_buffer_size) : 0;
default_grib_context.no_big_group_split = no_big_group_split ? atoi(no_big_group_split) : 0;
default_grib_context.no_spd = no_spd ? atoi(no_spd) : 0;
default_grib_context.keep_matrix = keep_matrix ? atoi(keep_matrix) : 1;
default_grib_context.write_on_fail = write_on_fail ? atoi(write_on_fail) : 0;
default_grib_context.no_abort = no_abort ? atoi(no_abort) : 0;
default_grib_context.debug = debug ? atoi(debug) : 0;
default_grib_context.gribex_mode_on = gribex ? atoi(gribex) : 0;
default_grib_context.inited = 1;
default_grib_context.io_buffer_size = io_buffer_size ? atoi(io_buffer_size) : 0;
default_grib_context.no_big_group_split = no_big_group_split ? atoi(no_big_group_split) : 0;
default_grib_context.no_spd = no_spd ? atoi(no_spd) : 0;
default_grib_context.keep_matrix = keep_matrix ? atoi(keep_matrix) : 1;
default_grib_context.write_on_fail = write_on_fail ? atoi(write_on_fail) : 0;
default_grib_context.no_abort = no_abort ? atoi(no_abort) : 0;
default_grib_context.debug = debug ? atoi(debug) : 0;
default_grib_context.gribex_mode_on = gribex ? atoi(gribex) : 0;
default_grib_context.large_constant_fields = large_constant_fields ? atoi(large_constant_fields) : 0;
default_grib_context.ieee_packing = ieee_packing ? atoi(ieee_packing) : 0;
default_grib_context.grib_samples_path = codes_getenv("ECCODES_SAMPLES_PATH");
default_grib_context.log_stream = stderr;
default_grib_context.ieee_packing = ieee_packing ? atoi(ieee_packing) : 0;
default_grib_context.grib_samples_path = codes_getenv("ECCODES_SAMPLES_PATH");
default_grib_context.log_stream = stderr;
if (!log_stream) {
default_grib_context.log_stream = stderr;
}
@ -538,21 +538,18 @@ grib_context* grib_context_get_default()
default_grib_context.grib_samples_path);
default_grib_context.keys_count = 0;
default_grib_context.keys = grib_hash_keys_new(&(default_grib_context),
&(default_grib_context.keys_count));
default_grib_context.keys = grib_hash_keys_new(&(default_grib_context), &(default_grib_context.keys_count));
default_grib_context.concepts_index = grib_itrie_new(&(default_grib_context),
&(default_grib_context.concepts_count));
default_grib_context.hash_array_index = grib_itrie_new(&(default_grib_context),
&(default_grib_context.hash_array_count));
default_grib_context.def_files = grib_trie_new(&(default_grib_context));
default_grib_context.lists = grib_trie_new(&(default_grib_context));
default_grib_context.classes = grib_trie_new(&(default_grib_context));
default_grib_context.bufrdc_mode = bufrdc_mode ? atoi(bufrdc_mode) : 0;
default_grib_context.concepts_index = grib_itrie_new(&(default_grib_context), &(default_grib_context.concepts_count));
default_grib_context.hash_array_index = grib_itrie_new(&(default_grib_context), &(default_grib_context.hash_array_count));
default_grib_context.def_files = grib_trie_new(&(default_grib_context));
default_grib_context.lists = grib_trie_new(&(default_grib_context));
default_grib_context.classes = grib_trie_new(&(default_grib_context));
default_grib_context.bufrdc_mode = bufrdc_mode ? atoi(bufrdc_mode) : 0;
default_grib_context.bufr_set_to_missing_if_out_of_range = bufr_set_to_missing_if_out_of_range ? atoi(bufr_set_to_missing_if_out_of_range) : 0;
default_grib_context.bufr_multi_element_constant_arrays = bufr_multi_element_constant_arrays ? atoi(bufr_multi_element_constant_arrays) : 0;
default_grib_context.grib_data_quality_checks = grib_data_quality_checks ? atoi(grib_data_quality_checks) : 0;
default_grib_context.file_pool_max_opened_files = file_pool_max_opened_files ? atoi(file_pool_max_opened_files) : DEFAULT_FILE_POOL_MAX_OPENED_FILES;
default_grib_context.bufr_multi_element_constant_arrays = bufr_multi_element_constant_arrays ? atoi(bufr_multi_element_constant_arrays) : 0;
default_grib_context.grib_data_quality_checks = grib_data_quality_checks ? atoi(grib_data_quality_checks) : 0;
default_grib_context.file_pool_max_opened_files = file_pool_max_opened_files ? atoi(file_pool_max_opened_files) : DEFAULT_FILE_POOL_MAX_OPENED_FILES;
}
GRIB_MUTEX_UNLOCK(&mutex_c);

View File

@ -547,12 +547,13 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm
(void)err; /* TODO */
}
#define MAX_STRING_SIZE 4096
static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_bufr_decode_C* self = (grib_dumper_bufr_decode_C*)d;
char* value = NULL;
char value[MAX_STRING_SIZE] = {0,}; /* See ECC-710 */
size_t size = MAX_STRING_SIZE;
char* p = NULL;
size_t size = 0;
grib_context* c = a->context;
int r = 0, err = 0;
grib_handle* h = grib_handle_of_accessor(a);
@ -560,23 +561,12 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0)
return;
_grib_get_string_length(a, &size);
if (size == 0)
return;
value = (char*)grib_context_malloc_clear(c, size);
if (!value) {
grib_context_log(c, GRIB_LOG_FATAL, "unable to allocate %d bytes", (int)size);
return;
}
self->empty = 0;
err = grib_unpack_string(a, value, &size);
p = value;
r = compute_bufr_key_rank(h, self->keys, a->name);
if (grib_is_missing_string(a, (unsigned char*)value, size)) {
grib_context_free(c, value);
return;
}
@ -613,7 +603,6 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
depth -= 2;
}
grib_context_free(c, value);
(void)err; /* TODO */
}

View File

@ -460,31 +460,21 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm
(void)err; /* TODO */
}
#define MAX_STRING_SIZE 4096
static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_bufr_decode_filter* self = (grib_dumper_bufr_decode_filter*)d;
char* value = NULL;
char* p = NULL;
size_t size = 0;
grib_context* c = a->context;
char value[MAX_STRING_SIZE] = {0,}; /* See ECC-710 */
size_t size = MAX_STRING_SIZE;
char* p = NULL;
grib_context* c = a->context;
int r =0, err = 0;
grib_handle* h = grib_handle_of_accessor(a);
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0)
return;
_grib_get_string_length(a, &size);
if (size == 0)
return;
value = (char*)grib_context_malloc_clear(c, size);
if (!value) {
grib_context_log(c, GRIB_LOG_FATAL, "unable to allocate %d bytes", (int)size);
return;
}
else
self->begin = 0;
self->begin = 0;
self->empty = 0;
@ -492,7 +482,6 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
p = value;
r = compute_bufr_key_rank(h, self->keys, a->name);
if (grib_is_missing_string(a, (unsigned char*)value, size)) {
grib_context_free(c, value);
return;
}
@ -528,7 +517,6 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
depth -= 2;
}
grib_context_free(c, value);
(void)err; /* TODO */
}

View File

@ -489,36 +489,26 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm
(void)err; /* TODO */
}
#define MAX_STRING_SIZE 4096
static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_bufr_decode_fortran* self = (grib_dumper_bufr_decode_fortran*)d;
char* value = NULL;
char* p = NULL;
size_t size = 0;
grib_context* c = a->context;
char value[MAX_STRING_SIZE] = {0,}; /* See ECC-710 */
size_t size = MAX_STRING_SIZE;
char* p = NULL;
grib_context* c = a->context;
int r = 0, err = 0;
grib_handle* h = grib_handle_of_accessor(a);
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0)
return;
_grib_get_string_length(a, &size);
if (size == 0)
return;
value = (char*)grib_context_malloc_clear(c, size);
if (!value) {
grib_context_log(c, GRIB_LOG_FATAL, "unable to allocate %d bytes", (int)size);
return;
}
self->empty = 0;
err = grib_unpack_string(a, value, &size);
p = value;
r = compute_bufr_key_rank(h, self->keys, a->name);
if (grib_is_missing_string(a, (unsigned char*)value, size)) {
grib_context_free(c, value);
return;
}
@ -556,7 +546,6 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
depth -= 2;
}
grib_context_free(c, value);
(void)err; /* TODO */
}

View File

@ -502,12 +502,13 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm
(void)err; /* TODO */
}
#define MAX_STRING_SIZE 4096
static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_bufr_decode_python* self = (grib_dumper_bufr_decode_python*)d;
char* value = NULL;
char value[MAX_STRING_SIZE] = {0,}; /* See ECC-710 */
char* p = NULL;
size_t size = 0;
size_t size = MAX_STRING_SIZE;
grib_context* c = a->context;
int r = 0, err = 0;
grib_handle* h = grib_handle_of_accessor(a);
@ -515,23 +516,12 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0)
return;
_grib_get_string_length(a, &size);
if (size == 0)
return;
value = (char*)grib_context_malloc_clear(c, size);
if (!value) {
grib_context_log(c, GRIB_LOG_FATAL, "unable to allocate %d bytes", (int)size);
return;
}
self->empty = 0;
err = grib_unpack_string(a, value, &size);
p = value;
r = compute_bufr_key_rank(h, self->keys, a->name);
if (grib_is_missing_string(a, (unsigned char*)value, size)) {
grib_context_free(c, value);
return;
}
@ -567,7 +557,6 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
depth -= 2;
}
grib_context_free(c, value);
(void)err; /* TODO */
}

View File

@ -694,18 +694,8 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
if (size == 0)
return;
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) {
/* ECC-356: Solution for the special local section key 'keyMore' and its alias 'ident' */
int skip = 1;
if ((a->flags & GRIB_ACCESSOR_FLAG_HIDDEN) != 0) {
if (strcmp(a->name, "keyMore") == 0 && grib_is_defined(h, "ls.ident")) {
skip = 0;
acc_name = "ident";
}
}
if (skip)
return;
}
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0)
return;
value = (char*)grib_context_malloc_clear(c, size);
if (!value) {

View File

@ -748,18 +748,8 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
if (size == 0)
return;
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) {
/* ECC-356: Solution for the special local section key 'keyMore' and its alias 'ident' */
int skip = 1;
if ((a->flags & GRIB_ACCESSOR_FLAG_HIDDEN) != 0) {
if (strcmp(a->name, "keyMore") == 0 && grib_is_defined(h, "ls.ident")) {
skip = 0;
acc_name = "ident";
}
}
if (skip)
return;
}
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0)
return;
value = (char*)grib_context_malloc_clear(c, size);
if (!value) {

View File

@ -691,18 +691,8 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
if (size == 0)
return;
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) {
/* ECC-356: Solution for the special local section key 'keyMore' and its alias 'ident' */
int skip = 1;
if ((a->flags & GRIB_ACCESSOR_FLAG_HIDDEN) != 0) {
if (strcmp(acc_name, "keyMore") == 0 && grib_is_defined(h, "ls.ident")) {
skip = 0;
acc_name = "ident";
}
}
if (skip)
return;
}
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0)
return;
value = (char*)grib_context_malloc_clear(c, size);
if (!value) {

View File

@ -628,12 +628,13 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm
(void)err; /* TODO */
}
#define MAX_STRING_SIZE 4096
static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_bufr_simple* self = (grib_dumper_bufr_simple*)d;
char* value = NULL;
char value[MAX_STRING_SIZE] = {0,}; /* See ECC-710 */
char* p = NULL;
size_t size = 0;
size_t size = MAX_STRING_SIZE;
grib_context* c = a->context;
int r = 0;
int is_missing = 0;
@ -641,32 +642,14 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
grib_handle* h = grib_handle_of_accessor(a);
const char* acc_name = a->name;
_grib_get_string_length(a, &size);
if (size == 0)
return;
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) {
/* ECC-356: Solution for the special local section key 'keyMore' and its alias 'ident' */
int skip = 1;
if ((a->flags & GRIB_ACCESSOR_FLAG_HIDDEN) != 0) {
if (strcmp(a->name, "keyMore") == 0 && grib_is_defined(h, "ls.ident")) {
skip = 0;
acc_name = "ident";
}
}
if (skip)
return;
}
value = (char*)grib_context_malloc_clear(c, size);
if (!value) {
grib_context_log(c, GRIB_LOG_FATAL, "unable to allocate %d bytes", (int)size);
return;
}
self->empty = 0;
err = grib_unpack_string(a, value, &size);
Assert(size < MAX_STRING_SIZE);
p = value;
r = compute_bufr_key_rank(h, self->keys, acc_name);
if (grib_is_missing_string(a, (unsigned char*)value, size)) {
@ -707,7 +690,6 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
grib_context_free(c, prefix);
}
grib_context_free(c, value);
(void)err; /* TODO */
}

View File

@ -450,24 +450,14 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_json* self = (grib_dumper_json*)d;
char value[MAX_STRING_SIZE] = {0,}; /* See ECC-710 */
size_t size = MAX_STRING_SIZE;
char* p = NULL;
size_t size = MAX_STRING_SIZE;
int is_missing = 0;
int err = 0;
const char* acc_name = a->name;
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) {
/* ECC-356: Solution for the special local section key 'keyMore' and its alias 'ident' */
int skip = 1;
if ((a->flags & GRIB_ACCESSOR_FLAG_HIDDEN) != 0) {
grib_handle* h = grib_handle_of_accessor(a);
if (strcmp(a->name, "keyMore") == 0 && grib_is_defined(h, "ls.ident")) {
skip = 0;
acc_name = "ident";
}
}
if (skip)
return;
return;
}
/* ECC-710: It is MUCH slower determining the string length here

View File

@ -116,14 +116,17 @@ grib_expression* new_sub_string_expression(grib_context* c, const char* value, s
if (length == 0) {
grib_context_log(c, GRIB_LOG_ERROR, "Invalid substring: length must be > 0");
grib_context_free_persistent(c, e);
return NULL;
}
if (start > slen) { /* to catch a -ve number passed to start */
grib_context_log(c, GRIB_LOG_ERROR, "Invalid substring: start=%lu", start);
grib_context_free_persistent(c, e);
return NULL;
}
if (start + length > slen) {
grib_context_log(c, GRIB_LOG_ERROR, "Invalid substring: start(=%lu)+length(=%lu) > length('%s'))", start, length, value);
grib_context_free_persistent(c, e);
return NULL;
}

View File

@ -255,6 +255,7 @@ grib_file* grib_file_open(const char* filename, const char* mode, int* err)
GRIB_MUTEX_UNLOCK(&mutex1);
return NULL;
}
if (file->mode) free(file->mode);
file->mode = strdup(mode);
if (file_pool.context->io_buffer_size) {
#ifdef POSIX_MEMALIGN

View File

@ -4140,3 +4140,73 @@ void unrotate(const double inlat, const double inlon,
*outlat = ret_lat;
*outlon = ret_lon;
}
#define RADIAN(x) ((x)*acos(0.0) / 90.0)
/* radius is in km, angles in degrees */
/* Spherical Law of Cosines */
double geographic_distance_spherical(double radius, double lon1, double lat1, double lon2, double lat2)
{
double rlat1 = RADIAN(lat1);
double rlat2 = RADIAN(lat2);
double rlon1 = lon1;
double rlon2 = lon2;
double a;
if (lat1 == lat2 && lon1 == lon2) {
return 0.0; /* the two points are identical */
}
if (rlon1 >= 360) rlon1 -= 360.0;
rlon1 = RADIAN(rlon1);
if (rlon2 >= 360) rlon2 -= 360.0;
rlon2 = RADIAN(rlon2);
a = sin(rlat1) * sin(rlat2) + cos(rlat1) * cos(rlat2) * cos(rlon2 - rlon1);
DebugAssert(a >= -1 && a <= 1);
return radius * acos(a);
}
/* major and minor axes in km, angles in degrees */
double geographic_distance_ellipsoid(double major, double minor, double lon1, double lat1, double lon2, double lat2)
{
/* Lambert's formula */
double rlat1 = RADIAN(lat1);
double rlat2 = RADIAN(lat2);
double rlon1 = RADIAN(lon1);
double rlon2 = RADIAN(lon2);
double deltaLat = rlat2 - rlat1;
double deltaLon = rlon2 - rlon1;
double sinDlat = sin(deltaLat/2.0);
double sinDlon = sin(deltaLon/2.0);
double sin2Dlat = sinDlat*sinDlat;
double sin2Dlon = sinDlon*sinDlon;
double a = sin2Dlat + cos(rlat1) * cos(rlat2) * sin2Dlon;
double c = 2 * atan2(sqrt(a), sqrt(1.0-a));
double f = (major - minor)/major; /*flattening*/
double latr1 = atan( (1.0-f)*tan(rlat1) ); /*Reduced latitude1*/
double latr2 = atan( (1.0-f)*tan(rlat2) ); /*Reduced latitude2*/
double P = (latr1+latr2)/2;
double Q = (latr2-latr1)/2;
double sinP = sin(P);
double sin2P = sinP*sinP;
double cosQ = cos(Q);
double cos2Q = cosQ*cosQ;
double cosc2 = cos(c/2);
double cos2c2 = cosc2*cosc2;
double sinQ = sin(Q);
double sin2Q = sinQ*sinQ;
double cosP = cos(P);
double cos2P = cosP*cosP;
double sinc2 = sin(c/2);
double sin2c2 = sinc2*sinc2;
double X = (c - sin(c))* sin2P * cos2Q / cos2c2;
double Y = (c + sin(c))*sin2Q*cos2P/sin2c2;
double dist = major * (c - f*(X+Y)/2);
return dist;
}

Some files were not shown because too many files have changed in this diff Show More