griblib

package
v1.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2020 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//ExportNone - do not export anything
	ExportNone = 0
	// PrintMessageDisciplines - only print disciplines for the sections
	PrintMessageDisciplines = 1
	// PrintMessageCategories - only print categories
	PrintMessageCategories = 2
	// ExportJSONToConsole - export json to console
	ExportJSONToConsole = 3
	// ExportToPNG - export data as a png
	ExportToPNG = 4
)
View Source
const (
	// LatitudeNorth is the north-most latitude value
	LatitudeNorth = 90000000
	// LatitudeSouth is the south-most latitude value
	LatitudeSouth = -90000000
	// LongitudeStart is the minimum value for longitude
	LongitudeStart = 0
	// LongitudeEnd is the maximum value for longitude
	LongitudeEnd = 360000000
)
View Source
const (
	//Grib is a magic-number specifying the grib2-format
	Grib = 0x47524942
	//EndSectionLength is the binary length of the end-section. Fixed number.
	EndSectionLength = 926365495
	//SupportedGribEdition is 2
	SupportedGribEdition = 2
)
View Source
const INT_MAX = 9223372036854775807

Variables

This section is empty.

Functions

func DisciplineDescription

func DisciplineDescription(value uint8) string

DisciplineDescription DisciplineDescription(Code table 0.0)

func EarthShapeDescription

func EarthShapeDescription(value int) string

EarthShapeDescription EarthShapeDescription Shape of the earth (Code table 3.2)

func Export

func Export(messages []*Message, options Options)

Export exports messages to the supported formats

func ExportMessageAsPng added in v1.2.5

func ExportMessageAsPng(message *Message, filename string) error

func ExportMessagesAsPngs

func ExportMessagesAsPngs(messages []*Message)

func FilterValuesFromGeoFilter

func FilterValuesFromGeoFilter(message *Message, filter GeoFilter) (*[]float64, error)

FilterValuesFromGeoFilter ...

func GridDefinitionSourceDescription

func GridDefinitionSourceDescription(value int) string

GridDefinitionSourceDescription GridDefinitionSourceDescription Source of Grid Definition (Code table 3.0)

func GridDefinitionTemplateDescription

func GridDefinitionTemplateDescription(value int) string

GridDefinitionTemplateDescription GridDefinitionTemplateDescription Grid Definition Template Number (Code table 3.1)

func GridPointPositionDescription

func GridPointPositionDescription(value int) string

GridPointPositionDescription Grid point position (code table 3.8)

func LocalTableVersionNumber

func LocalTableVersionNumber(value int) string

LocalTableVersionNumber LocalTableVersionNumber (Code table 1.1)

func MasterTableDescription

func MasterTableDescription(value int) string

MasterTableDescription MasterTableDescription version number (Code table 1.0)

func MaxMin

func MaxMin(float64s []float64) (float64, float64)

func ParseData0

func ParseData0(dataReader io.Reader, dataLength int, template *Data0) ([]float64, error)

ParseData0 parses data0 struct from the reader into the an array of floating-point values

func ParseData2

func ParseData2(dataReader io.Reader, dataLength int, template *Data2) ([]float64, error)

ParseData2 parses data2 struct from the reader into the an array of floating-point values

func ParseData3

func ParseData3(dataReader io.Reader, dataLength int, template *Data3) ([]float64, error)

ParseData3 parses data3 struct from the reader into the an array of floating-point values

func ReadAerosolPresence

func ReadAerosolPresence(value int) string

ReadAerosolPresence Aerosol presence (code table 4.205)

func ReadAerosolType

func ReadAerosolType(value int) string

ReadAerosolType Aerosol Type (code table 4.233)

func ReadBitMapIndicator

func ReadBitMapIndicator(value int) string

ReadBitMapIndicator ReadBitMapIndicator is a Bit Map Indicator (code table 6.0)

func ReadCategoricalOutlook

func ReadCategoricalOutlook(value int) string

ReadCategoricalOutlook Categorical Outlook (code table 4.224)

func ReadCategoricalResult

func ReadCategoricalResult(value int) string

ReadCategoricalResult Categorical Result (code table 4.222)

func ReadCloudMaskType

func ReadCloudMaskType(value int) string

ReadCloudMaskType Cloud mask type (code table 4.217)

func ReadCloudTopHeightQuality

func ReadCloudTopHeightQuality(value int) string

ReadCloudTopHeightQuality Cloud top height quality indicator (code table 4.219)

func ReadCloudType

func ReadCloudType(value int) string

ReadCloudType Cloud type (code table 4.203)

func ReadClusteringMethod

func ReadClusteringMethod(value int) string

ReadClusteringMethod Clustering Method (code table 4.8)

func ReadClutterFillerIndicator

func ReadClutterFillerIndicator(value int) string

ReadClutterFillerIndicator Clutter Filter Indicator (code table 4.14)

func ReadCompressionType

func ReadCompressionType(value int) string

ReadCompressionType ReadCompressionType maps Type of compression (code table 5.40)

func ReadContrailEngineType

func ReadContrailEngineType(value int) string

ReadContrailEngineType Contrail engine type (code table 4.211)

func ReadContrailIntensity

func ReadContrailIntensity(value int) string

ReadContrailIntensity Contrail intensity (code table 4.210)

func ReadDataRepresentationTemplateNumber

func ReadDataRepresentationTemplateNumber(value int) string

ReadDataRepresentationTemplateNumber Data Representation Template Number (code table 5.0)

func ReadDataType

func ReadDataType(value uint8) string

ReadDataType Type of data (Code table 1.4)

func ReadDerivedForecast

func ReadDerivedForecast(value int) string

ReadDerivedForecast Derived forecast (code table 4.7)

func ReadEnsembleForecastType

func ReadEnsembleForecastType(value int) string

ReadEnsembleForecastType Type of ensemble forecast (code table 4.6)

func ReadFireDetection

func ReadFireDetection(value int) string

ReadFireDetection Fire Detection Indicator (code table 4.223)

func ReadFloatingPointNumbersPrecision

func ReadFloatingPointNumbersPrecision(value int) string

ReadFloatingPointNumbersPrecision ReadFloatingPointNumbersPrecision maps Precision of floating-point numbers to a string (code table 5.7)

func ReadGeneratingProcessType

func ReadGeneratingProcessType(value int) string

ReadGeneratingProcessType Type of generating process (code table 4.3)

func ReadGroupSplittingMethod

func ReadGroupSplittingMethod(value int) string

ReadGroupSplittingMethod ReadGroupSplittingMethod - Group Splitting Method (code table 5.4)

func ReadHorizontalDimensionProcessed

func ReadHorizontalDimensionProcessed(value int) string

ReadHorizontalDimensionProcessed Horizontal dimension processed (code table 4.220)

func ReadHorizontalLineType

func ReadHorizontalLineType(value int) string

ReadHorizontalLineType Type of horizontal line (Code table 3.20)

func ReadIcing

func ReadIcing(value int) string

ReadIcing Icing (code table 4.207)

func ReadIntervalType

func ReadIntervalType(value int) string

ReadIntervalType Type of interval

func ReadLandUse

func ReadLandUse(value int) string

ReadLandUse Land use (code table 4.212)

func ReadListInterpretation

func ReadListInterpretation(value int) string

ReadListInterpretation Interpretation of list of numbers defining number of points (Code table 3.11)

func ReadMatrixCoordinateParameter

func ReadMatrixCoordinateParameter(value int) string

ReadMatrixCoordinateParameter Matrix coordinate parameter (code table 5.3)

func ReadMatrixCoordinateValueFunctionDefinition

func ReadMatrixCoordinateValueFunctionDefinition(value int) string

ReadMatrixCoordinateValueFunctionDefinition Matrix coordinate value function definition (code table 5.2)

func ReadMissingDataTreatment

func ReadMissingDataTreatment(value int) string

ReadMissingDataTreatment Treatment of missing data (code table 4.221)

func ReadMissingValueManagement

func ReadMissingValueManagement(value int) string

ReadMissingValueManagement ReadMissingValueManagement - Missing Value Management for Complex Packing (code table 5.5)

func ReadOperatingMode

func ReadOperatingMode(value int) string

ReadOperatingMode Operating Mode (code table 4.12)

func ReadOriginalFieldValuesType

func ReadOriginalFieldValuesType(value int) string

ReadOriginalFieldValuesType Type of original field values (code table 5.1)

func ReadPixelSceneType

func ReadPixelSceneType(value int) string

ReadPixelSceneType Pixel scene type (code table 4.218)

func ReadPlanetaryBoundaryLayerRegime

func ReadPlanetaryBoundaryLayerRegime(value int) string

ReadPlanetaryBoundaryLayerRegime Planetary boundary layer regime (code table 4.209)

func ReadPrecipitableWaterCategory

func ReadPrecipitableWaterCategory(value int) string

ReadPrecipitableWaterCategory Precipitable water category (code table 4.202)

func ReadPrecipitationType

func ReadPrecipitationType(value int) string

ReadPrecipitationType Precipitation Type (code table 4.201)

func ReadProbabilityType

func ReadProbabilityType(value int) string

ReadProbabilityType Probability Type (code table 4.9)

func ReadProductDefinitionTemplateNumber

func ReadProductDefinitionTemplateNumber(value uint16) string

ReadProductDefinitionTemplateNumber Category Definition Template Number (Code table 4.0)

func ReadProductDisciplineCategoryParameters

func ReadProductDisciplineCategoryParameters(discipline uint16, category uint8, number uint8) string

ReadProductDisciplineCategoryParameters Parameter number by product discipline and parameter category (code table 4.2)

func ReadProductDisciplineParameters

func ReadProductDisciplineParameters(discipline uint8, category uint8) string

ReadProductDisciplineParameters Discipline of parameters by product discipline (Code table 4.1)

func ReadProductionStatus

func ReadProductionStatus(value int) string

ReadProductionStatus Production status of data(Code table 1.3)

func ReadQualityControlIndicator

func ReadQualityControlIndicator(value int) string

ReadQualityControlIndicator Quality Control Indicator (code table 4.13)

func ReadReferenceTimeSignificance

func ReadReferenceTimeSignificance(value int) string

ReadReferenceTimeSignificance Significance of reference time (Code table 1.2)

func ReadRemotelySensedSnowCoverage

func ReadRemotelySensedSnowCoverage(value int) string

ReadRemotelySensedSnowCoverage Remotely Sensed Snow Coverage (code table 4.215)

func ReadSnowCoveredTerrainElevation

func ReadSnowCoveredTerrainElevation(value int) string

ReadSnowCoveredTerrainElevation Elevation of Snow Covered Terrain (code table 4.216)

func ReadSoilType

func ReadSoilType(value int) string

ReadSoilType Soil type (code table 4.213)

func ReadSpatialDifferencingOrder

func ReadSpatialDifferencingOrder(value int) string

ReadSpatialDifferencingOrder ReadSpatialDifferencingOrder Order of Spatial Differencing (code table 5.6)

func ReadSpatialProcessingType

func ReadSpatialProcessingType(value int) string

ReadSpatialProcessingType TYPE OF SPATIAL PROCESSING USED TO ARRIVE AT A GIVEN DATA VALUE FROM THE SOURCE DATA (code table 4.15)

func ReadSpectralDataRepresentationMode

func ReadSpectralDataRepresentationMode(value int) string

ReadSpectralDataRepresentationMode SpectralDataRepresentationModeDescription Spectral data representation mode (Code table 3.7)

func ReadStatisticalProcessingType

func ReadStatisticalProcessingType(value int) string

ReadStatisticalProcessingType Type of statistical processing (code table 4.10)

func ReadSurfaceTypesUnits

func ReadSurfaceTypesUnits(value int) string

ReadSurfaceTypesUnits Fixed surface types and units (code table 4.5)

func ReadThunderstormCoverage

func ReadThunderstormCoverage(value int) string

ReadThunderstormCoverage Thunderstorm coverage (code table 4.204)

func ReadTimeIntervalsType

func ReadTimeIntervalsType(value int) string

ReadTimeIntervalsType Type of time intervals (code table 4.11)

func ReadTimeRangeUnitIndicator

func ReadTimeRangeUnitIndicator(value int) string

ReadTimeRangeUnitIndicator Indicator of unit of time range (code table 4.4)

func ReadTurbulence

func ReadTurbulence(value int) string

ReadTurbulence Turbulence (code table 4.208)

func ReadVerticalCoordinatePhysicalMeaning

func ReadVerticalCoordinatePhysicalMeaning(value int) string

ReadVerticalCoordinatePhysicalMeaning Physical meaning of vertical coordinate (Code table 3.15)

func ReadVerticalDimensionCoordinateValuesDefinition

func ReadVerticalDimensionCoordinateValuesDefinition(value int) string

ReadVerticalDimensionCoordinateValuesDefinition Vertical dimension coordinate values definition (Code table 3.21)

func ReadVolcanicAsh

func ReadVolcanicAsh(value int) string

ReadVolcanicAsh Volcanic ash (code table 4.206)

func ReadWindGeneratedWaveSpectralDescription

func ReadWindGeneratedWaveSpectralDescription(value int) string

ReadWindGeneratedWaveSpectralDescription Wind-Generated Wave Sectral Description (code table 4.235)

func RedValue

func RedValue(value float64, maxValue float64, minValue float64) uint8

RedValue returns a number between 0 and 255

func Reduce

func Reduce(readSeeker io.Reader, options Options, content chan []byte, end chan bool)

Reduce the file in readseeker with the given options, omitting all other products and areas

func SpectralDataRepresentationTypeDescription

func SpectralDataRepresentationTypeDescription(value int) string

SpectralDataRepresentationTypeDescription SpectralDataRepresentationTypeDescription Spectral data representation type (Code table 3.6)

func StartStopIndexes

func StartStopIndexes(filter GeoFilter, grid Grid0) (uint32, uint32, uint32, uint32)

StartStopIndexes ...

Types

type BasicAngle

type BasicAngle struct {
	BasicAngle    uint32 `json:"basicAngle"`
	BasicAngleSub uint32 `json:"basicAngleSub"`
}

BasicAngle specifies the angle of a grid

type BitReader

type BitReader struct {
	// contains filtered or unexported fields
}

BitReader is undocomented

type Data0

type Data0 struct {
	Reference    float32 `json:"reference"`
	BinaryScale  uint16  `json:"binaryScale"`
	DecimalScale uint16  `json:"decimalScale"`
	Bits         uint8   `json:"bits"`
	Type         uint8   `json:"type"`
}

Data0 is a Grid point data - simple packing http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-0.shtml

| Octet Number | Content
-----------------------------------------------------------------------------------------
| 12-15	     | Reference value (R) (IEEE 32-bit floating-point value)
| 16-17	     | Binary scale factor (E)
| 18-19	     | Decimal scale factor (D)
| 20	         | Number of bits used for each packed value for simple packing, or for each
|              | group reference value for complex packing or spatial differencing
| 21           | Type of original field values
|              |    - 0 : Floating point
|              |    - 1 : Integer
|              |    - 2-191 : reserved
|              |    - 192-254 : reserved for Local Use
|              |    - 255 : missing

type Data2

type Data2 struct {
	Data0
	GroupMethod            uint8  `json:"groupMethod"`            // 22
	MissingValue           uint8  `json:"missingValue"`           // 23
	MissingSubstitute1     uint32 `json:"missingSubstitute1"`     // 24-27
	MissingSubstitute2     uint32 `json:"missingSubstitute2"`     // 28-31
	NG                     uint32 `json:"ng"`                     // 32-35
	GroupWidths            uint8  `json:"groupWidths"`            // 36
	GroupWidthsBits        uint8  `json:"groupWidthsBits"`        // 37
	GroupLengthsReference  uint32 `json:"groupLengthsReference"`  // 38-41
	GroupLengthIncrement   uint8  `json:"groupLengthIncrement"`   // 42
	GroupLastLength        uint32 `json:"groupLastLength"`        // 43-46
	GroupScaledLengthsBits uint8  `json:"groupScaledLengthsBits"` // 47
}

Data2 is a Grid point data - complex packing http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-2.shtml

| Octet Number | Content
-----------------------------------------------------------------------------------------
| 12-15	     | Reference value (R) (IEEE 32-bit floating-point value)
| 16-17	     | Binary scale factor (E)
| 18-19	     | Decimal scale factor (D)
| 20	         | Number of bits used for each packed value for simple packing, or for each
|              | group reference value for complex packing or spatial differencing
| 21           | Type of original field values
|              |    - 0 : Floating point
|              |    - 1 : Integer
|              |    - 2-191 : reserved
|              |    - 192-254 : reserved for Local Use
|              |    - 255 : missing
| 22           | Group splitting method used (see Code Table 5.4)
|              |    - 0 : Row by Row Splitting
|              |    - 1 : General Group Splitting
|              |    - 2-191 : Reserved
|              |    - 192-254 : Reserved for Local Use
|              |    - 255 : Missing
| 23           | Missing value management used (see Code Table 5.5)
|              |    - 0 : No explicit missing values included within the data values
|              |    - 1 : Primary missing values included within the data values
|              |    - 2 : Primary and secondary missing values included within the data values
|              |    - 3-191 : Reserved
|              |    - 192-254 : Reserved for Local Use
|              |    - 255 : Missing
| 24-27        | Primary missing value substitute
| 28-31        | Secondary missing value substitute
| 32-35        | NG ― number of groups of data values into which field is split
| 36           | Reference for group widths (see Note 12)
| 37           | Number of bits used for the group widths (after the reference value in octet 36
|              | has been removed)
| 38-41        | Reference for group lengths (see Note 13)
| 42           | Length increment for the group lengths (see Note 14)
| 43-46        | True length of last group
| 47           | Number of bits used for the scaled group lengths (after subtraction of the
|              | reference value given in octets 38-41 and division by the length increment
|              | given in octet 42)

type Data3

type Data3 struct {
	Data2
	SpatialOrderDifference uint8 `json:"spatialOrderDifference"`
	OctetsNumber           uint8 `json:"octetsNumber"`
}

Data3 is a Grid point data - complex packing and spatial differencing http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_temp5-3.shtml

type GeoFilter

type GeoFilter struct {
	MinLat  int32 `json:"minLat"`
	MaxLat  int32 `json:"maxLat"`
	MinLong int32 `json:"minLong"`
	MaxLong int32 `json:"maxLong"`
}

GeoFilter is used to filter values. Only values inside the filter is returned when using this filter

type Grid

type Grid interface {
	Export() map[string]string
}

Grid is an interface for all grids.

func ReadGrid

func ReadGrid(f io.Reader, templateNumber uint16) (Grid, error)

ReadGrid reads grid from binary input to the grid-number specified by templateNumber

type Grid0

type Grid0 struct {
	//Name :=  "Latitude/longitude (or equidistant cylindrical, or Plate Carree) "
	GridHeader
	Ni                          uint32     `json:"ni"`
	Nj                          uint32     `json:"nj"`
	BasicAngle                  BasicAngle `json:"basicAngle"`
	La1                         int32      `json:"la1"`
	Lo1                         int32      `json:"lo1"`
	ResolutionAndComponentFlags uint8      `json:"resolutionAndComponentFlags"`
	La2                         int32      `json:"la2"`
	Lo2                         int32      `json:"lo2"`
	Di                          int32      `json:"di"`
	Dj                          int32      `json:"dj"`
	ScanningMode                uint8      `json:"scanningMode"`
}

Grid0 Definition Template 3.0: Latitude/longitude (or equidistant cylindrical, or Plate Carree)

func (*Grid0) Export

func (h *Grid0) Export() map[string]string

Export Grid0 to a map[string]string

type Grid10

type Grid10 struct {
	//name :=  "Mercator"
	GridHeader
	Ni                          uint32 `json:"ni"`
	Nj                          int32  `json:"nj"`
	La1                         int32  `json:"la1"`
	Lo1                         int32  `json:"lo1"`
	ResolutionAndComponentFlags uint8  `json:"resolutionAndComponentFlags"`
	Lad                         int32  `json:"lad"`
	La2                         int32  `json:"la2"`
	Lo2                         int32  `json:"lo2"`
	ScanningMode                uint8  `json:"scanningMode"`
	GridOrientation             uint32 `json:"gridOrientation"`
	Di                          int32  `json:"di"`
	Dj                          int32  `json:"dj"`
}

Grid10 Definition Template 3.10: Mercator

type Grid20

type Grid20 struct {
	//name =  "Polar stereographic projection ";
	GridHeader
	Nx                          uint32 `json:"nx"`
	Ny                          uint32 `json:"ny"`
	La1                         int32  `json:"na1"`
	Lo1                         int32  `json:"lo1"`
	ResolutionAndComponentFlags uint8  `json:"resolutionAndComponentFlags"`
	Lad                         int32  `json:"lad"`
	Lov                         int32  `json:"lov"`
	Dx                          int32  `json:"dx"`
	Dy                          int32  `json:"dy"`
	ProjectionCenter            uint8  `json:"projectionCenter"`
	ScanningMode                uint8  `json:"scanningMode"`
}

Grid20 Definition Template 3.20: Polar stereographic projection

type Grid30

type Grid30 struct {
	//name =  "Polar stereographic projection ";
	GridHeader
	Nx                          uint32 `json:"nx"`
	Ny                          uint32 `json:"ny"`
	La1                         int32  `json:"la1"`
	Lo1                         int32  `json:"lo1"`
	ResolutionAndComponentFlags uint8  `json:"resolutionAndComponentFlags"`
	Lad                         int32  `json:"lad"`
	Lov                         int32  `json:"lov"`
	Dx                          int32  `json:"dx"`
	Dy                          int32  `json:"dy"`
	ProjectionCenter            uint8  `json:"projectionCenter"`
	ScanningMode                uint8  `json:"scanningMode"`
	Latin1                      uint32 `json:"latin1"`
	Latin2                      uint32 `json:"latin2"`
	LaSouthPole                 uint32 `json:"laSouthPole"`
	LoSouthPole                 uint32 `json:"loSouthPole"`
}

Grid30 Definition Template 3.30: Lambert conformal

type Grid40

type Grid40 struct {
	//name =  "Gaussian latitude/longitude ";
	GridHeader
	Ni                          uint32 `json:"ni"`
	Nj                          uint32 `json:"nj"`
	BasicAngle                  uint32 `json:"basicAngle"`
	La1                         int32  `json:"la1"`
	Lo1                         int32  `json:"lo1"`
	ResolutionAndComponentFlags uint8  `json:"resolutionAndComponentFlags"`
	La2                         int32  `json:"la2"`
	Lo2                         int32  `json:"lo2"`
	Di                          int32  `json:"di"`
	N                           uint32 `json:"n"`
	ScanningMode                uint8  `json:"scanningMode"`
}

Grid40 Definition Template 3.40: Gaussian latitude/longitude

type Grid90

type Grid90 struct {
	//name =  "Space view perspective or orthographic ";
	GridHeader
	Nx uint32 `json:"nx"`
	Ny uint32 `json:"ny"`
	//BasicAngle                  BasicAngle
	Lap                         int32  `json:"lap"`
	Lop                         int32  `json:"lop"`
	ResolutionAndComponentFlags uint8  `json:"resolutionAndComponentFlags"`
	Dx                          uint32 `json:"dx"`
	Dy                          uint32 `json:"dy"`
	Xp                          uint32 `json:"xp"`
	Yp                          uint32 `json:"yp"`
	ScanningMode                uint8  `json:"scanningMode"`
	Orientation                 uint32 `json:"orientation"`
	Nr                          uint32 `json:"nr"`
	Xo                          uint32 `json:"xo"`
	Yo                          uint32 `json:"yo"`
}

Grid90 Definition Template 3.90: Space view perspective or orthographic FIXME: implement properly Grid90

type GridHeader

type GridHeader struct {
	EarthShape      uint8       `json:"earthShape"`
	SphericalRadius ScaledValue `json:"sphericalRadius"`
	MajorAxis       ScaledValue `json:"majorAxis"`
	MinorAxis       ScaledValue `json:"minorAxis"`
}

GridHeader is a common header in all grids

func (*GridHeader) Export

func (h *GridHeader) Export() (d map[string]string)

Export gridheader to a map[string]string

type Message

type Message struct {
	Section0 Section0
	Section1 Section1
	Section2 Section2
	Section3 Section3
	Section4 Section4
	Section5 Section5
	Section6 Section6
	Section7 Section7
}

Message is the entire message for a data-layer

func Filter

func Filter(messages []*Message, options Options) []*Message

Filter messages with values from options

func ReadMessage

func ReadMessage(gribFile io.Reader) (*Message, error)

ReadMessage reads the actual messages from a gribfile-reader (io.Reader from either file, http or any other io.Reader)

func ReadMessages

func ReadMessages(gribFile io.Reader) ([]*Message, error)

ReadMessages reads all message from gribFile

func (Message) Data

func (message Message) Data() []float64

Data returns the data as an array of float64

type Options

type Options struct {
	Operation               string    `json:"operation"`
	Discipline              int       `json:"discipline"` // -1 means all disciplines
	DataExport              bool      `json:"dataExport"`
	Category                int       `json:"category"` // -1 means all categories
	Filepath                string    `json:"filePath"`
	ReduceFilePath          string    `json:"reduceFilePath"`
	ExportType              int       `json:"exportType"`
	MaximumNumberOfMessages int       `json:"maximumNumberOfMessages"`
	GeoFilter               GeoFilter `json:"geoFilter"`
	Surface                 Surface   `json:"surfaceFilter"`
}

Options is used to filter messages.

type Product0

type Product0 struct {
	// category 0 is temperature, see http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-1.shtml
	ParameterCategory uint8   `json:"parameterCategory"`
	ParameterNumber   uint8   `json:"parameterNumber"`
	ProcessType       uint8   `json:"processType"`
	BackgroundProcess uint8   `json:"backgroundProcess"`
	AnalysisProcess   uint8   `json:"analysisProcess"`
	Hours             uint16  `json:"hours"`
	Minutes           uint8   `json:"minutes"`
	TimeUnitIndicator uint8   `json:"timeUnitIndicator"`
	ForecastTime      uint32  `json:"forecastTime"`
	FirstSurface      Surface `json:"firstSurface"`
	SecondSurface     Surface `json:"secondSurface"`
}

Product0 http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-0.shtml Analysis or forecast at a horizontal level or in a horizontal layer at a point in time

type Product1

type Product1 struct {
	Product0
	EnsembleForecastType    uint8 `json:"ensembleForecastType"`
	PertubationNumber       uint8 `json:"pertubationNumber"`
	ForecastInEnsembleCount uint8 `json:"forecastInEnsembleCount"`
}

Product1 http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_temp4-1.shtml

type Product2

type Product2 struct {
	Product0
	DerivedForecast         uint8 `json:"derivedForecast"`
	ForecastInEnsembleCount uint8 `json:"forecastInEnsembleCount"`
}

Product2 http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_temp4-2.shtml

type Product5

type Product5 struct {
	Product0
	ForecastProbabilityNumber  uint8  `json:"forecastProbabilityNumber"`
	TotalForecastProbabilities uint8  `json:"totalForecastProbabilities"`
	ProbabilityType            uint8  `json:"probabilityType"`
	ScaleFactorLowerLimit      uint8  `json:"scaleFactorLowerLimit"`
	ScaleValueLowerLimit       uint32 `json:"scaleValueLowerLimit"`
	ScaleFactorUpperLimit      uint8  `json:"scaleFactorUpperLimit"`
	ScaleValueUpperLimit       uint32 `json:"scaleValueUpperLimit"`
}

Product5 http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_temp4-5.shtml

type Product6

type Product6 struct {
	Product0
	PercentileValue uint8 `json:"percentileValue"` // 0-100
}

Product6 http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_temp4-6.shtml

type Product8

type Product8 struct {
	Product0
	Time                              Time                     `json:"time"`
	NumberOfIntervalTimeRanges        uint8                    `json:"numberOfIntervalTimeRanges"` // length of last datatype
	TotalMissingDataValuesCount       uint32                   `json:"totalMissingDataValuesCount"`
	TimeRangeSpecification1           TimeRangeSpecification   `json:"timeRangeSpecification1"`
	TimeRangeSpecification2           TimeRangeSpecification   `json:"timeRangeSpecification2"`           // 59-70
	AdditionalTimeRangeSpecifications []TimeRangeSpecification `json:"additionalTimeRangeSpecifications"` // 71-n
}

Product8 http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_temp4-8.shtml

type ScaledValue

type ScaledValue struct {
	Scale uint8  `json:"scale"`
	Value uint32 `json:"value"`
}

ScaledValue specifies the scale of a value

type Section0

type Section0 struct {
	Indicator     uint32 `json:"indicator"`
	Reserved      uint16 `json:"reserved"`
	Discipline    uint8  `json:"discipline"`
	Edition       uint8  `json:"edition"`
	MessageLength uint64 `json:"messageLength"`
}

Section0 is the indicator section http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_sect0.shtml This section serves to identify the start of the record in a human readable form, indicate the total length of the message, and indicate the Edition number of GRIB used to construct or encode the message. For GRIB2, this section is always 16 octets long.

| Octet Number | Content
-----------------------------------------------------------------------------------------
| 1-4          | 'GRIB' (Coded according to the International Alphabet Number 5)
| 5-6          | reserved
| 7            | Discipline (From Table 0.0)
| 8            | Edition number - 2 for GRIB2
| 9-16         | Total length of GRIB message in octets (All sections);

func ReadSection0

func ReadSection0(reader io.Reader) (section0 Section0, err error)

ReadSection0 reads Section0 from an io.reader

type Section1

type Section1 struct {
	OriginatingCenter         uint16 `json:"ooriginatingCenter"`
	OriginatingSubCenter      uint16 `json:"originatingSubCenter"`
	MasterTablesVersion       uint8  `json:"masterTablesVersion"`
	LocalTablesVersion        uint8  `json:"localTablesVersion"`
	ReferenceTimeSignificance uint8  `json:"referenceTimeSignificance"` // Table 1.2, value 1 is start of forecast
	ReferenceTime             Time   `json:"referenceTime"`
	ProductionStatus          uint8  `json:"productionStatus"`
	Type                      uint8  `json:"type"` // data type, Table 1.4, value 1 is forecast products
}

func ReadSection1

func ReadSection1(f io.Reader, length int) (section Section1, err error)

ReadSection1 is poorly documented other than code

type Section2

type Section2 struct {
	LocalUse []uint8 `json:"localUse"`
}

Section2 is the Local Use section http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect2.shtml

| Octet Number | Content
-----------------------------------------------------------------------------------------
| 1-4          | Length of the section in octets (N)
| 5            | Number of the section (2)
| 6-N          | Local Use

Center=7 (NCEP), subcenter=14(NWS Meteorological Development Laboratory (MDL)) used octet 6 to indicate which local use table to use. For MDL, octet 6=1 indicates use: "MDL Template 2.1"

func ReadSection2

func ReadSection2(f io.Reader, len int) (section Section2, err error)

ReadSection2 is for "Local use"

type Section3

type Section3 struct {
	Source                   uint8       `json:"source"`
	DataPointCount           uint32      `json:"datapointCount"`
	PointCountOctets         uint8       `json:"pointCountOctets"`
	PointCountInterpretation uint8       `json:"pointCountInterpretation"`
	TemplateNumber           uint16      `json:"templateNumber"`
	Definition               interface{} `json:"definition"`
}

Section3 is the Grid Definition section http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect3.shtml It contains information of the grid(earth shape, long, lat, etc)

| Octet Number | Content
-----------------------------------------------------------------------------------------
| 1-4          | Length of the section in octets (nn)
| 5            | Number of the section (3)
| 6            | Source of grid definition (See Table 3.0) (See note 1 below)
| 7-10         | Number of data points
| 11           | Number of octets for optional list of numbers defining number of points (See note 2 below)
| 12           | Interpetation of list of numbers defining number of points (See Table 3.11)
| 13-14        | Grid definition template number (= N) (See Table 3.1)
| 15-xx        | Grid definition template (See Template 3.N, where N is the grid definition template
|              | number given in octets 13-14)
| [xx+1]-nn    | Optional list of numbers defining number of points (See notes 2, 3, and 4 below)

If octet 6 is not zero, octets 15-xx (15-nn if octet 11 is zero) may not be supplied. This should be documented with all bits set to 1 in the grid definition template number.

An optional list of numbers defining number of points is used to document a quasi-regular grid, where the number of points may vary from one row to another. In such a case, octet 11 is non zero and gives the number octets on which each number of points is encoded. For all other cases, such as regular grids, octets 11 and 12 are zero and no list is appended to the grid definition template.

If a list of numbers defining the number of points is preset, it is appended at the end of the grid definition template ( or directly after the grid definition number if the template is missing). When the grid definition template is present, the length is given according to bit 3 of the scanning mode flag octet (length is Nj or Ny for flag value 0). List ordering is implied by data scanning.

Depending on the code value given in octet 12, the list of numbers either:

  • Corresponds to the coordinate lines as given in the grid definition, or
  • Corresponds to a full circle, or
  • Does not apply.

func ReadSection3

func ReadSection3(f io.Reader, _ int) (section Section3, err error)

ReadSection3 reads section3 from reader(f). the Lenght parameter is ignored

func (Section3) String

func (s Section3) String() string

type Section4

type Section4 struct {
	CoordinatesCount                uint16   `json:"coordinatesCount"`
	ProductDefinitionTemplateNumber uint16   `json:"productDefinitionTemplateNumber"`
	ProductDefinitionTemplate       Product0 `json:"productDefinitionTemplate"` // FIXME, support more products
	Coordinates                     []byte   `json:"coordinates"`
}

Section4 is the Product Definition Section http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect4.shtml

| Octet Number | Content
-----------------------------------------------------------------------------------------
| 1-4          | Length of the section in octets (nn)
| 5            | Number of the section (4)
| 6-7          | Number of coordinate values after template (See note 1 below)
| 8-9          | Product definition template number (See Table 4.0)
| 10-xx        | Product definition template (See product template 4.X, where X is
|              | the number given in octets 8-9)
| [xx+1]-nn    | Optional list of coordinate values (See notes 2 and 3 below)

Coordinate values are intended to document the vertical discretization associated with model data on hybrid coordinate vertical levels. A value of zero in octets 6-7 indicates that no such values are present. Otherwise the number corresponds to the whole set of values.

Hybrid systems employ a means of representing vertical coordinates in terms of a mathematical combination of pressure and sigma coordinates. When used in conjunction with a surface pressure field and an appropriate mathematical expression, the vertical coordinate parameters may be used to interpret the hybrid vertical coordinate.

Hybrid coordinate values, if present, should be encoded in IEEE 32-bit floating point format. They are intended to be encoded as pairs.

func ReadSection4

func ReadSection4(f io.Reader, length int) (section Section4, err error)

ReadSection4 reads section4 from an io.Reader

type Section5

type Section5 struct {
	PointsNumber       uint32 `json:"pointsNumber"`
	DataTemplateNumber uint16 `json:"dataTemplateNumber"`
	//DataTemplate       Data3  `json:"dataTemplate"` // FIXME, support more data-types
	Data []byte `json:"dataTemplate"`
}

Section5 is Data Representation section http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect5.shtml

| Octet Number | Content
-----------------------------------------------------------------------------------------
| 1-4          | Length of the section in octets (nn)
| 5            | Number of the section (5)
| 6-9          | Number of data points where one or more values are specified in Section 7 when a bit map is present,
|              | total number of data points when a bit map is absent.
| 10-11        | Data representation template number (See Table 5.0 http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-0.shtml)
| 12-nn        | Data representation template (See Template 5.X, where X is the number given in octets 10-11)

func ReadSection5

func ReadSection5(f io.Reader, length int) (section Section5, err error)

ReadSection5 is poorly documented other than code

func (Section5) GetDataTemplate

func (section Section5) GetDataTemplate() (interface{}, error)

GetDataTemplate extract DataTemplate from the section

type Section6

type Section6 struct {
	BitmapIndicator uint8  `json:"bitmapIndicator"`
	Bitmap          []byte `json:"bitmap"`
}

Section6 is the Bit-Map section http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect6.shtml

| Octet Number | Content
-----------------------------------------------------------------------------------------
| 1-4          | Length of the section in octets (nn)
| 5            | Number of the section (6)
| 6            | Bit-map indicator (See Table 6.0) (See note 1 below)
| 7-nn         | Bit-map

If octet 6 is not zero, the length of this section is 6 and octets 7-nn are not present.

func ReadSection6

func ReadSection6(f io.Reader, length int) (section Section6, err error)

ReadSection6 is poorly documented other than code

type Section7

type Section7 struct {
	Data []float64 `json:"data"`
}

Section7 is the Data section http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect7.shtml

| Octet Number | Content
-----------------------------------------------------------------------------------------
| 1-4          | Length of the section in octets (nn)
| 5            | Number of the section (7)
| 6-nn         | Data in a format described by data Template 7.X, where X is the data representation template number
|              | given in octets 10-11 of Section 5.

func ReadSection7

func ReadSection7(f io.Reader, length int, section5 Section5) (section Section7, sectionError error)

ReadSection7 reads the actual data

type SectionHead

type SectionHead struct {
	ByteLength uint32 `json:"byteLength"`
	Number     uint8  `json:"number"`
}

SectionHead is the common header for each section1-8

| Octet Number | Content
-----------------------------------------------------------
| 1-4          | Length of the section in octets (21 or N)
| 5            | Number of the section (1)

func ReadSectionHead

func ReadSectionHead(section io.Reader) (head SectionHead, err error)

ReadSectionHead is poorly documented other than code

func (SectionHead) ContentLength

func (s SectionHead) ContentLength() int

ContentLength returns the binary length of the sectionhead

func (SectionHead) SectionNumber

func (s SectionHead) SectionNumber() uint8

SectionNumber returns the number of the sectionhead

func (SectionHead) String

func (s SectionHead) String() string

type Surface

type Surface struct {
	Type  uint8  `json:"type"` // type 220: Planetary Boundary Layer
	Scale uint8  `json:"scale"`
	Value uint32 `json:"value"` // e.g. meters above sea-level
}

Surface describes a surface for a product, see http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_table4-5.shtml

type Time

type Time struct {
	Year   uint16 `json:"year"`   // year
	Month  uint8  `json:"month"`  // month + 1
	Day    uint8  `json:"day"`    // day
	Hour   uint8  `json:"hour"`   // hour
	Minute uint8  `json:"minute"` // minute
	Second uint8  `json:"second"` // second
}

Time is the time of section 1

| Octet Number | Content
---------------------------------
| 13-14        | Year (4 digits)
| 15           | Month
| 16           | Day
| 17           | Hour
| 18           | Minute
| 19           | Second

type TimeRangeSpecification

type TimeRangeSpecification struct {
	StatisticalFieldCalculationProcess                     uint8  `json:"statisticalFieldCalculationProcess"`                     // 47
	IncrementBetweenSuccessiveFieldsType                   uint8  `json:"incrementBetweenSuccessiveFieldsType"`                   // 48
	IncrementBetweenSuccessiveFieldsRangeTimeUnitIndicator uint8  `json:"incrementBetweenSuccessiveFieldsRangeTimeUnitIndicator"` // 49
	StatististicalProcessTimeLength                        uint32 `json:"statististicalProcessTimeLength"`                        // 50-53
	IncrementBetweenSuccessiveFieldsTimeUnitIndicator      uint8  `json:"incrementBetweenSuccessiveFieldsTimeUnitIndicator"`      // 54
	TimeIncrementBetweenSuccessiveField                    uint32 `json:"timeIncrementBetweenSuccessiveField"`                    // 55-58
}

TimeRangeSpecification describes timerange for products

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL