UNPKG

eccodes-ts

Version:

TypeScript wrapper for eccodes GRIB file handling

362 lines (360 loc) 32.4 kB
var Z = Object.defineProperty; var z = (s, d, n) => d in s ? Z(s, d, { enumerable: !0, configurable: !0, writable: !0, value: n }) : s[d] = n; var k = (s, d, n) => z(s, typeof d != "symbol" ? d + "" : d, n); import { spawn as B } from "child_process"; import * as $ from "readline"; import * as L from "fs"; import * as j from "os"; import * as q from "path"; var E = /* @__PURE__ */ ((s) => (s[s.Waves = 0] = "Waves", s[s.Currents = 1] = "Currents", s[s.Ice = 2] = "Ice", s[s.SurfaceProperties = 3] = "SurfaceProperties", s[s.SubSurfaceProperties = 4] = "SubSurfaceProperties", s[s.Miscellaneous = 191] = "Miscellaneous", s[s.Missing = 255] = "Missing", s))(E || {}), i = /* @__PURE__ */ ((s) => (s.Meters = "m", s.Seconds = "s", s.Kilograms = "kg", s.Kelvin = "K", s.Pascals = "Pa", s.Newtons = "N", s.Watts = "W", s.Joules = "J", s.Degrees = "°", s.DegreeTrue = "degree true", s.DegreesLatLon = "deg", s.MetersPerSecond = "m s-1", s.MetersPerSecondSquared = "m s-2", s.SquareMetersPerSecond = "m2 s-1", s.SquareMetersPerSecondSquared = "m2 s-2", s.SquareMeters = "m2", s.CubicMeters = "m3", s.CubicMetersPerSquareMeter = "m3m-2", s.NewtonsPerSquareMeter = "N m-2", s.NewtonsPerSquareMeterSeconds = "N m-2 s", s.PascalsPerSecond = "Pa s-1", s.PascalMeters = "Pa m", s.NewtonsPerMeter = "N m-1", s.WattsPerSquareMeter = "W m-2", s.WattsPerMeter = "W m-1", s.JoulesPerKilogram = "J kg-1", s.JoulesPerSquareMeter = "J m-2", s.KilogramsPerCubicMeter = "kg m-3", s.KilogramsPerSquareMeter = "kg m-2", s.KelvinSquareMetersPerKilogramPerSecond = "K m2 kg-1 s-1", s.KelvinMetersPerSecond = "K*m s-1", s.PerSecond = "s-1", s.Knots = "kt", s.Fraction = "fraction", s.Proportion = "proportion", s.Numeric = "Numeric", s.Percentage = "%", s))(i || {}), A = /* @__PURE__ */ ((s) => (s[s.WaveSpectra1 = 0] = "WaveSpectra1", s[s.WaveSpectra2 = 1] = "WaveSpectra2", s[s.WaveSpectra3 = 2] = "WaveSpectra3", s[s.SignificantHeightCombined = 3] = "SignificantHeightCombined", s[s.WindWaveDirection = 4] = "WindWaveDirection", s[s.WindWaveHeight = 5] = "WindWaveHeight", s[s.WindWavePeriod = 6] = "WindWavePeriod", s[s.SwellWaveDirection = 7] = "SwellWaveDirection", s[s.SwellWaveHeight = 8] = "SwellWaveHeight", s[s.SwellWavePeriod = 9] = "SwellWavePeriod", s[s.PrimaryWaveDirection = 10] = "PrimaryWaveDirection", s[s.PrimaryWavePeriod = 11] = "PrimaryWavePeriod", s[s.SecondaryWaveDirection = 12] = "SecondaryWaveDirection", s[s.SecondaryWavePeriod = 13] = "SecondaryWavePeriod", s[s.CombinedWaveDirection = 14] = "CombinedWaveDirection", s[s.CombinedWavePeriod = 15] = "CombinedWavePeriod", s[s.DragCoefficient = 16] = "DragCoefficient", s[s.FrictionVelocity = 17] = "FrictionVelocity", s[s.WaveStress = 18] = "WaveStress", s[s.NormalisedWaveStress = 19] = "NormalisedWaveStress", s[s.MeanSquareSlope = 20] = "MeanSquareSlope", s[s.StokesDriftU = 21] = "StokesDriftU", s[s.StokesDriftV = 22] = "StokesDriftV", s[s.MaxWaveHeightPeriod = 23] = "MaxWaveHeightPeriod", s[s.MaxWaveHeight = 24] = "MaxWaveHeight", s[s.InverseMeanFrequency = 25] = "InverseMeanFrequency", s[s.InverseMeanFrequencyWind = 26] = "InverseMeanFrequencyWind", s[s.InverseMeanFrequencySwell = 27] = "InverseMeanFrequencySwell", s[s.MeanZeroCrossingPeriod = 28] = "MeanZeroCrossingPeriod", s[s.MeanZeroCrossingPeriodWind = 29] = "MeanZeroCrossingPeriodWind", s[s.MeanZeroCrossingPeriodSwell = 30] = "MeanZeroCrossingPeriodSwell", s[s.WaveDirectionalWidth = 31] = "WaveDirectionalWidth", s[s.WindWaveDirectionalWidth = 32] = "WindWaveDirectionalWidth", s[s.SwellDirectionalWidth = 33] = "SwellDirectionalWidth", s[s.PeakWavePeriod = 34] = "PeakWavePeriod", s[s.PeakPeriodWindWaves = 35] = "PeakPeriodWindWaves", s[s.PeakPeriodSwell = 36] = "PeakPeriodSwell", s[s.AltimeterWaveHeight = 37] = "AltimeterWaveHeight", s[s.AltimeterCorrectedWaveHeight = 38] = "AltimeterCorrectedWaveHeight", s[s.AltimeterRangeCorrection = 39] = "AltimeterRangeCorrection", s[s.NeutralWindSpeed10m = 40] = "NeutralWindSpeed10m", s[s.WindDirection10m = 41] = "WindDirection10m", s[s.WaveEnergySpectrum = 42] = "WaveEnergySpectrum", s[s.WaveElevationKurtosis = 43] = "WaveElevationKurtosis", s[s.BenjaminFeirIndex = 44] = "BenjaminFeirIndex", s[s.SpectralPeakedness = 45] = "SpectralPeakedness", s[s.PeakWaveDirection = 46] = "PeakWaveDirection", s[s.SwellHeight1 = 47] = "SwellHeight1", s[s.SwellHeight2 = 48] = "SwellHeight2", s[s.SwellHeight3 = 49] = "SwellHeight3", s[s.SwellPeriod1 = 50] = "SwellPeriod1", s[s.SwellPeriod2 = 51] = "SwellPeriod2", s[s.SwellPeriod3 = 52] = "SwellPeriod3", s[s.SwellDirection1 = 53] = "SwellDirection1", s[s.SwellDirection2 = 54] = "SwellDirection2", s[s.SwellDirection3 = 55] = "SwellDirection3", s[s.SwellDirectionalWidth1 = 56] = "SwellDirectionalWidth1", s[s.SwellDirectionalWidth2 = 57] = "SwellDirectionalWidth2", s[s.SwellDirectionalWidth3 = 58] = "SwellDirectionalWidth3", s[s.SwellFrequencyWidth1 = 59] = "SwellFrequencyWidth1", s[s.SwellFrequencyWidth2 = 60] = "SwellFrequencyWidth2", s[s.SwellFrequencyWidth3 = 61] = "SwellFrequencyWidth3", s[s.WaveFrequencyWidth = 62] = "WaveFrequencyWidth", s[s.WindWaveFrequencyWidth = 63] = "WindWaveFrequencyWidth", s[s.TotalSwellFrequencyWidth = 64] = "TotalSwellFrequencyWidth", s[s.SwellPeakPeriod1 = 65] = "SwellPeakPeriod1", s[s.SwellPeakPeriod2 = 66] = "SwellPeakPeriod2", s[s.SwellPeakPeriod3 = 67] = "SwellPeakPeriod3", s[s.SwellPeakDirection1 = 68] = "SwellPeakDirection1", s[s.SwellPeakDirection2 = 69] = "SwellPeakDirection2", s[s.SwellPeakDirection3 = 70] = "SwellPeakDirection3", s[s.WindWavePeakDirection = 71] = "WindWavePeakDirection", s[s.TotalSwellPeakDirection = 72] = "TotalSwellPeakDirection", s[s.WhitecapFraction = 73] = "WhitecapFraction", s[s.TotalSwellMeanDirection = 74] = "TotalSwellMeanDirection", s[s.WindWaveMeanDirection = 75] = "WindWaveMeanDirection", s[s.Charnock = 76] = "Charnock", s[s.WaveSpectralSkewness = 77] = "WaveSpectralSkewness", s[s.WaveEnergyFluxMagnitude = 78] = "WaveEnergyFluxMagnitude", s[s.WaveEnergyFluxDirection = 79] = "WaveEnergyFluxDirection", s[s.WaveAngularFrequencyWidthRatio = 80] = "WaveAngularFrequencyWidthRatio", s[s.FreeConvectiveVelocity = 81] = "FreeConvectiveVelocity", s[s.AirDensity = 82] = "AirDensity", s[s.NormalizedWaveEnergyFlux = 83] = "NormalizedWaveEnergyFlux", s[s.NormalizedOceanStress = 84] = "NormalizedOceanStress", s[s.NormalizedOceanEnergyFlux = 85] = "NormalizedOceanEnergyFlux", s[s.SurfaceElevationVariance = 86] = "SurfaceElevationVariance", s[s.WaveInducedMeanSeaLevel = 87] = "WaveInducedMeanSeaLevel", s[s.SpectralWidthIndex = 88] = "SpectralWidthIndex", s[s.FreakWaveEventCount = 89] = "FreakWaveEventCount", s[s.SurfaceMomentumFluxU = 90] = "SurfaceMomentumFluxU", s[s.SurfaceMomentumFluxV = 91] = "SurfaceMomentumFluxV", s[s.WaveTurbulentEnergyFlux = 92] = "WaveTurbulentEnergyFlux", s[s.EnvelopeMaxWaveHeight = 93] = "EnvelopeMaxWaveHeight", s[s.TimeDomainMaxCrestHeight = 94] = "TimeDomainMaxCrestHeight", s[s.TimeDomainMaxWaveHeight = 95] = "TimeDomainMaxWaveHeight", s[s.SpaceTimeMaxCrestHeight = 96] = "SpaceTimeMaxCrestHeight", s[s.SpaceTimeMaxWaveHeight = 97] = "SpaceTimeMaxWaveHeight", s[s.GodaPeakednessFactor = 98] = "GodaPeakednessFactor", s[s.WaveSteepness = 192] = "WaveSteepness", s[s.WaveLength = 193] = "WaveLength", s[s.Missing = 255] = "Missing", s))(A || {}), J = ((s) => (s[s.Meters = i.Meters] = "Meters", s[s.Seconds = i.Seconds] = "Seconds", s[s.DegreeTrue = i.DegreeTrue] = "DegreeTrue", s[s.MetersPerSecond = i.MetersPerSecond] = "MetersPerSecond", s[s.NewtonsPerSquareMeter = i.NewtonsPerSquareMeter] = "NewtonsPerSquareMeter", s[s.WattsPerMeter = i.WattsPerMeter] = "WattsPerMeter", s[s.KilogramsPerCubicMeter = i.KilogramsPerCubicMeter] = "KilogramsPerCubicMeter", s[s.WattsPerSquareMeter = i.WattsPerSquareMeter] = "WattsPerSquareMeter", s[s.SquareMeters = i.SquareMeters] = "SquareMeters", s[s.Fraction = i.Fraction] = "Fraction", s[s.Numeric = i.Numeric] = "Numeric", s[s.Proportion = i.Proportion] = "Proportion", s))(J || {}), v = /* @__PURE__ */ ((s) => (s[s.WindDirection = 0] = "WindDirection", s[s.WindSpeed = 1] = "WindSpeed", s[s.UComponentWind = 2] = "UComponentWind", s[s.VComponentWind = 3] = "VComponentWind", s[s.StreamFunction = 4] = "StreamFunction", s[s.VelocityPotential = 5] = "VelocityPotential", s[s.MontgomeryStreamFunction = 6] = "MontgomeryStreamFunction", s[s.SigmaCoordinateVerticalVelocity = 7] = "SigmaCoordinateVerticalVelocity", s[s.VerticalVelocityPressure = 8] = "VerticalVelocityPressure", s[s.VerticalVelocityGeometric = 9] = "VerticalVelocityGeometric", s[s.AbsoluteVorticity = 10] = "AbsoluteVorticity", s[s.AbsoluteDivergence = 11] = "AbsoluteDivergence", s[s.RelativeVorticity = 12] = "RelativeVorticity", s[s.RelativeDivergence = 13] = "RelativeDivergence", s[s.PotentialVorticity = 14] = "PotentialVorticity", s[s.VerticalUComponentShear = 15] = "VerticalUComponentShear", s[s.VerticalVComponentShear = 16] = "VerticalVComponentShear", s[s.MomentumFluxU = 17] = "MomentumFluxU", s[s.MomentumFluxV = 18] = "MomentumFluxV", s[s.WindMixingEnergy = 19] = "WindMixingEnergy", s[s.BoundaryLayerDissipation = 20] = "BoundaryLayerDissipation", s[s.MaximumWindSpeed = 21] = "MaximumWindSpeed", s[s.WindSpeedGust = 22] = "WindSpeedGust", s[s.UComponentWindGust = 23] = "UComponentWindGust", s[s.VComponentWindGust = 24] = "VComponentWindGust", s[s.VerticalSpeedShear = 25] = "VerticalSpeedShear", s[s.HorizontalMomentumFlux = 26] = "HorizontalMomentumFlux", s[s.UComponentStormMotion = 27] = "UComponentStormMotion", s[s.VComponentStormMotion = 28] = "VComponentStormMotion", s[s.DragCoefficient = 29] = "DragCoefficient", s[s.FrictionalVelocity = 30] = "FrictionalVelocity", s[s.TurbulentDiffusionCoefficientMomentum = 31] = "TurbulentDiffusionCoefficientMomentum", s[s.EtaCoordinateVerticalVelocity = 32] = "EtaCoordinateVerticalVelocity", s[s.WindFetch = 33] = "WindFetch", s[s.NormalWindComponent = 34] = "NormalWindComponent", s[s.TangentialWindComponent = 35] = "TangentialWindComponent", s[s.AmplitudeFunctionRossbyWave = 36] = "AmplitudeFunctionRossbyWave", s[s.NorthwardTurbulentSurfaceStress = 37] = "NorthwardTurbulentSurfaceStress", s[s.EastwardTurbulentSurfaceStress = 38] = "EastwardTurbulentSurfaceStress", s[s.EastwardWindTendencyParamaterizations = 39] = "EastwardWindTendencyParamaterizations", s[s.NorthwardWindTendencyParamaterizations = 40] = "NorthwardWindTendencyParamaterizations", s[s.UComponentGeostrophicWind = 41] = "UComponentGeostrophicWind", s[s.VComponentGeostrophicWind = 42] = "VComponentGeostrophicWind", s[s.GeostrophicWindDirection = 43] = "GeostrophicWindDirection", s[s.GeostrophicWindSpeed = 44] = "GeostrophicWindSpeed", s[s.UnbalancedComponentDivergence = 45] = "UnbalancedComponentDivergence", s[s.VorticityAdvection = 46] = "VorticityAdvection", s[s.SurfaceRoughnessHeat = 47] = "SurfaceRoughnessHeat", s[s.SurfaceRoughnessMoisture = 48] = "SurfaceRoughnessMoisture", s[s.WindStress = 49] = "WindStress", s[s.EastwardWindStress = 50] = "EastwardWindStress", s[s.NorthwardWindStress = 51] = "NorthwardWindStress", s[s.UComponentWindStress = 52] = "UComponentWindStress", s[s.VComponentWindStress = 53] = "VComponentWindStress", s[s.NaturalLogSurfaceRoughnessHeat = 54] = "NaturalLogSurfaceRoughnessHeat", s[s.NaturalLogSurfaceRoughnessMoisture = 55] = "NaturalLogSurfaceRoughnessMoisture", s[s.UComponentNeutralWind = 56] = "UComponentNeutralWind", s[s.VComponentNeutralWind = 57] = "VComponentNeutralWind", s[s.TurbulentSurfaceStressMagnitude = 58] = "TurbulentSurfaceStressMagnitude", s[s.VerticalDivergence = 59] = "VerticalDivergence", s[s.DragThermalCoefficient = 60] = "DragThermalCoefficient", s[s.DragEvaporationCoefficient = 61] = "DragEvaporationCoefficient", s[s.EastwardTurbulentSurfaceStress2 = 62] = "EastwardTurbulentSurfaceStress2", s[s.NorthwardTurbulentSurfaceStress2 = 63] = "NorthwardTurbulentSurfaceStress2", s[s.EastwardTurbulentSurfaceStressOrographic = 64] = "EastwardTurbulentSurfaceStressOrographic", s[s.NorthwardTurbulentSurfaceStressOrographic = 65] = "NorthwardTurbulentSurfaceStressOrographic", s[s.EastwardTurbulentSurfaceStressSurfaceRoughness = 66] = "EastwardTurbulentSurfaceStressSurfaceRoughness", s[s.NorthwardTurbulentSurfaceStressSurfaceRoughness = 67] = "NorthwardTurbulentSurfaceStressSurfaceRoughness", s[s.VerticalSpeedShearLocal = 192] = "VerticalSpeedShearLocal", s[s.HorizontalMomentumFluxLocal = 193] = "HorizontalMomentumFluxLocal", s[s.UComponentStormMotionLocal = 194] = "UComponentStormMotionLocal", s[s.VComponentStormMotionLocal = 195] = "VComponentStormMotionLocal", s[s.DragCoefficientLocal = 196] = "DragCoefficientLocal", s[s.FrictionalVelocityLocal = 197] = "FrictionalVelocityLocal", s[s.LatitudeUWindComponent = 198] = "LatitudeUWindComponent", s[s.LongitudeUWindComponent = 199] = "LongitudeUWindComponent", s[s.LatitudeVWindComponent = 200] = "LatitudeVWindComponent", s[s.LongitudeVWindComponent = 201] = "LongitudeVWindComponent", s[s.LatitudePressurePoint = 202] = "LatitudePressurePoint", s[s.LongitudePressurePoint = 203] = "LongitudePressurePoint", s[s.VerticalEddyDiffusivityHeat = 204] = "VerticalEddyDiffusivityHeat", s[s.CovarianceMeridionalZonalWind = 205] = "CovarianceMeridionalZonalWind", s[s.CovarianceTemperatureZonalWind = 206] = "CovarianceTemperatureZonalWind", s[s.CovarianceTemperatureMeridionalWind = 207] = "CovarianceTemperatureMeridionalWind", s[s.VerticalDiffusionZonalAcceleration = 208] = "VerticalDiffusionZonalAcceleration", s[s.VerticalDiffusionMeridionalAcceleration = 209] = "VerticalDiffusionMeridionalAcceleration", s[s.GravityWaveDragZonalAcceleration = 210] = "GravityWaveDragZonalAcceleration", s[s.GravityWaveDragMeridionalAcceleration = 211] = "GravityWaveDragMeridionalAcceleration", s[s.ConvectiveZonalMomentumMixingAcceleration = 212] = "ConvectiveZonalMomentumMixingAcceleration", s[s.ConvectiveMeridionalMomentumMixingAcceleration = 213] = "ConvectiveMeridionalMomentumMixingAcceleration", s[s.VerticalVelocityTendency = 214] = "VerticalVelocityTendency", s[s.OmegaDividedByDensity = 215] = "OmegaDividedByDensity", s[s.ConvectiveGravityWaveDragZonalAcceleration = 216] = "ConvectiveGravityWaveDragZonalAcceleration", s[s.ConvectiveGravityWaveDragMeridionalAcceleration = 217] = "ConvectiveGravityWaveDragMeridionalAcceleration", s[s.VelocityPointModelSurface = 218] = "VelocityPointModelSurface", s[s.PotentialVorticityMassWeighted = 219] = "PotentialVorticityMassWeighted", s[s.HourlyMaxUpwardVerticalVelocity = 220] = "HourlyMaxUpwardVerticalVelocity", s[s.HourlyMaxDownwardVerticalVelocity = 221] = "HourlyMaxDownwardVerticalVelocity", s[s.UComponentHourlyMax10mWindSpeed = 222] = "UComponentHourlyMax10mWindSpeed", s[s.VComponentHourlyMax10mWindSpeed = 223] = "VComponentHourlyMax10mWindSpeed", s[s.VentilationRate = 224] = "VentilationRate", s[s.TransportWindSpeed = 225] = "TransportWindSpeed", s[s.TransportWindDirection = 226] = "TransportWindDirection", s[s.EarliestReasonableArrivalTime = 227] = "EarliestReasonableArrivalTime", s[s.MostLikelyArrivalTime = 228] = "MostLikelyArrivalTime", s[s.MostLikelyDepartureTime = 229] = "MostLikelyDepartureTime", s[s.LatestReasonableDepartureTime = 230] = "LatestReasonableDepartureTime", s[s.TropicalWindDirection = 231] = "TropicalWindDirection", s[s.TropicalWindSpeed = 232] = "TropicalWindSpeed", s[s.InflowBasedShearMagnitude = 233] = "InflowBasedShearMagnitude", s[s.UComponentInflowBasedShearVector = 234] = "UComponentInflowBasedShearVector", s[s.VComponentInflowBasedShearVector = 235] = "VComponentInflowBasedShearVector", s[s.UComponentBunkersEffectiveRight = 236] = "UComponentBunkersEffectiveRight", s[s.VComponentBunkersEffectiveRight = 237] = "VComponentBunkersEffectiveRight", s[s.Missing = 255] = "Missing", s))(v || {}), _ = ((s) => (s[s.Degrees = i.Degrees] = "Degrees", s[s.MetersPerSecond = i.MetersPerSecond] = "MetersPerSecond", s[s.SquareMetersPerSecond = i.SquareMetersPerSecond] = "SquareMetersPerSecond", s[s.SquareMetersPerSecondSquared = i.SquareMetersPerSecondSquared] = "SquareMetersPerSecondSquared", s[s.PerSecond = i.PerSecond] = "PerSecond", s[s.PascalsPerSecond = i.PascalsPerSecond] = "PascalsPerSecond", s[s.KelvinSquareMetersPerKilogramPerSecond = i.KelvinSquareMetersPerKilogramPerSecond] = "KelvinSquareMetersPerKilogramPerSecond", s[s.NewtonsPerSquareMeter = i.NewtonsPerSquareMeter] = "NewtonsPerSquareMeter", s[s.Joules = i.Joules] = "Joules", s[s.WattsPerSquareMeter = i.WattsPerSquareMeter] = "WattsPerSquareMeter", s[s.Meters = i.Meters] = "Meters", s[s.Numeric = i.Numeric] = "Numeric", s[s.NewtonsPerSquareMeterSeconds = i.NewtonsPerSquareMeterSeconds] = "NewtonsPerSquareMeterSeconds", s[s.MetersPerSecondSquared = i.MetersPerSecondSquared] = "MetersPerSecondSquared", s[s.Knots = i.Knots] = "Knots", s[s.DegreesLatLon = i.DegreesLatLon] = "DegreesLatLon", s[s.KelvinMetersPerSecond = i.KelvinMetersPerSecond] = "KelvinMetersPerSecond", s[s.Seconds = i.Seconds] = "Seconds", s))(_ || {}), K = /* @__PURE__ */ ((s) => (s[s.Temperature = 0] = "Temperature", s[s.Moisture = 1] = "Moisture", s[s.Momentum = 2] = "Momentum", s[s.Mass = 3] = "Mass", s[s.ShortWaveRadiation = 4] = "ShortWaveRadiation", s[s.LongWaveRadiation = 5] = "LongWaveRadiation", s[s.Cloud = 6] = "Cloud", s[s.ThermodynamicStabilityIndices = 7] = "ThermodynamicStabilityIndices", s[s.KinematicStabilityIndices = 8] = "KinematicStabilityIndices", s[s.TemperatureProbabilities = 9] = "TemperatureProbabilities", s[s.MoistureProbabilities = 10] = "MoistureProbabilities", s[s.MomentumProbabilities = 11] = "MomentumProbabilities", s[s.MassProbabilities = 12] = "MassProbabilities", s[s.Aerosols = 13] = "Aerosols", s[s.TraceGases = 14] = "TraceGases", s[s.Radar = 15] = "Radar", s[s.ForecastRadarImagery = 16] = "ForecastRadarImagery", s[s.Electrodynamics = 17] = "Electrodynamics", s[s.NuclearRadiology = 18] = "NuclearRadiology", s[s.PhysicalAtmosphericProperties = 19] = "PhysicalAtmosphericProperties", s[s.AtmosphericChemicalConstituents = 20] = "AtmosphericChemicalConstituents", s[s.ThermodynamicProperties = 21] = "ThermodynamicProperties", s[s.DroughtIndices = 22] = "DroughtIndices", s[s.CCITTIA5String = 190] = "CCITTIA5String", s[s.Miscellaneous = 191] = "Miscellaneous", s[s.Covariance = 192] = "Covariance", s[s.Missing = 255] = "Missing", s))(K || {}); const G = [ "parameterCategory", "parameterNumber", "parameterName", "parameterUnits", "shortName", "dataDate", "dataTime", "forecastTime", "maximum", "minimum", "average", "values" ].join(","), t = [ "gridType", "Ni", "Nj", "latitudeOfFirstGridPointInDegrees", "longitudeOfFirstGridPointInDegrees", "latitudeOfLastGridPointInDegrees", "longitudeOfLastGridPointInDegrees", "iDirectionIncrementInDegrees", "jDirectionIncrementInDegrees", "centre", "editionNumber", "typeOfGeneratingProcess", "generatingProcessIdentifier", "numberOfValues", "numberOfMissing", "getNumberOfValues" ].join(","), H = class H { constructor(d) { k(this, "tempFilePath", null); k(this, "gribFilePath"); k(this, "initPromise", null); if (!(d != null && d.trim())) throw new Error("Input source cannot be empty"); if (this.isValidUrl(d)) this.gribFilePath = this.createTempFile(), this.initPromise = this.fetchAndSaveFile(d); else { const n = this.resolveFilePath(d); if (!L.existsSync(n)) throw new Error(`File not found: ${n}`); this.gribFilePath = n; } } resolveFilePath(d) { if (q.isAbsolute(d)) return d; const n = q.resolve(process.cwd(), d); try { if (!L.statSync(n).isFile()) throw new Error(`Path exists but is not a file: ${n}`); return n; } catch (S) { if (S.code === "ENOENT") { const f = this.findProjectRoot(process.cwd()); if (f) { const D = q.resolve(f, d); if (L.existsSync(D)) return D; } } throw S; } } findProjectRoot(d) { let n = d; for (; n !== q.parse(n).root; ) { if (L.existsSync(q.join(n, "package.json"))) return n; n = q.dirname(n); } return null; } isValidUrl(d) { try { const n = new URL(d); return n.protocol === "http:" || n.protocol === "https:"; } catch { return !1; } } async fetchAndSaveFile(d, n = {}) { const { timeout: S = H.DEFAULT_TIMEOUT, retries: f = H.DEFAULT_RETRIES } = n; let D = null; for (let w = 1; w <= f; w++) try { const y = new AbortController(), V = setTimeout(() => y.abort(), S), C = await fetch(d, { signal: y.signal }); if (clearTimeout(V), !C.ok) throw new Error(`HTTP error! status: ${C.status}`); const x = await C.arrayBuffer(); await L.promises.writeFile( this.gribFilePath, Buffer.from(x) ); const T = await L.promises.open(this.gribFilePath, "r"); await T.sync(), await T.close(); return; } catch (y) { if (D = y, w === f) throw await this.cleanup(), new Error( `Failed to fetch GRIB file after ${f} attempts: ${D.message}` ); await new Promise( (V) => setTimeout(V, Math.pow(2, w) * 1e3) ); } } createTempFile() { const d = q.join( j.tmpdir(), `grib-${Date.now()}-${Math.random().toString(36).slice(2)}.grib2` ); return this.tempFilePath = d, d; } async execGribCommandStream(d, n = G) { this.initPromise && await this.initPromise; try { await L.promises.access(this.gribFilePath, L.constants.R_OK); } catch (S) { throw S instanceof Error ? new Error(`GRIB file not accessible: ${S.message}`) : new Error("GRIB file not accessible"); } try { return await new Promise((S, f) => { const D = []; let w = {}, y = "", V = ""; const C = d ? `-w ${d}` : "", x = ["-j"]; C && x.push(...C.split(" ")), x.push("-p", n, this.gribFilePath); const T = B("grib_dump", x); T.on("error", (F) => { F.code === "ENOENT" ? f( new Error( `grib_dump command not found. Please ensure eccodes is installed: - On MacOS: brew install eccodes - On Ubuntu: apt-get install libeccodes-dev libeccodes-tools- On Windows: Install WSL and use Ubuntu package If already installed, check if grib_dump is in your PATH` ) ) : f(F); }), $.createInterface({ input: T.stdout, crlfDelay: 1 / 0 }).on("line", (F) => { const R = F.trim(); if (R && (V += R, R.endsWith("},") || R.endsWith("}"))) try { const W = JSON.parse( V.replace(/,$/, "") ); W.key && W.value !== void 0 && (w[W.key] = W.value), V = ""; } catch { Object.keys(w).length > 0 && (D.push({ ...w }), w = {}); } }), T.stderr.on("data", (F) => { y += F.toString(); }), T.on("close", (F) => { if (F !== 0) { f(new Error(`grib_dump failed: ${y}`)); return; } Object.keys(w).length > 0 && D.push({ ...w }), S(D); }), T.on("error", (F) => { f(new Error(`Failed to spawn grib_dump: ${F.message}`)); }); }); } finally { this.tempFilePath && await this.cleanup(); } } async execFullGribDump() { return new Promise((d, n) => { let S = "", f = ""; const D = B("grib_dump", ["-j", this.gribFilePath]); D.stdout.on("data", (w) => { S += w.toString(); }), D.stderr.on("data", (w) => { f += w.toString(); }), D.on("close", (w) => { if (w !== 0) { n(new Error(`grib_dump failed: ${f}`)); return; } try { const V = JSON.parse(S).messages.map( (C) => { const x = C.map(({ key: T, value: l }) => [T, l]); return Object.fromEntries(x); } ); d(V); } catch (y) { n(new Error(`Failed to parse GRIB data: ${y}`)); } }), D.on("error", (w) => { n(new Error(`Failed to spawn grib_dump: ${w.message}`)); }); }); } getCommandStreamParams({ discipline: d, category: n, number: S }) { const f = []; return d !== void 0 && f.push(`discipline=${d}`), n !== void 0 && f.push(`parameterCategory=${n}`), S !== void 0 && f.push(`parameterNumber=${S}`), f.join(","); } mapValuesToLatLon(d) { const n = new Array(d.length); let S = 0; for (let f = 0; f < 721; f++) { const D = 90 - f * 0.25; for (let w = 0; w < 1440; w++) { const y = w * 0.25, V = y > 180 ? y - 360 : y; n[S] = { lat: D, lon: V, value: d[S] }, S++; } } return n; } addLatLonToGribValues(d) { return d.map((n) => ({ ...n, values: Array.isArray(n.values) ? this.mapValuesToLatLon(n.values) : [] })); } async getSignificantWaveHeight(d) { const n = await this.execGribCommandStream( this.getCommandStreamParams({ category: E.Waves, number: A.SignificantHeightCombined }) ); return d != null && d.addLatLon ? this.addLatLonToGribValues(n) : n; } async getPrimaryWavePeriod(d) { const n = await this.execGribCommandStream( this.getCommandStreamParams({ category: E.Waves, number: A.PrimaryWavePeriod }) ); return d != null && d.addLatLon ? this.addLatLonToGribValues(n) : n; } async getSignificantWindWaveHeight(d) { const n = await this.execGribCommandStream( this.getCommandStreamParams({ category: E.Waves, number: A.WindWaveHeight }) ); return d != null && d.addLatLon ? this.addLatLonToGribValues(n) : n; } async getPrimaryWaveDirection(d) { const n = await this.execGribCommandStream( this.getCommandStreamParams({ category: E.Waves, number: A.PrimaryWaveDirection }) ); return d != null && d.addLatLon ? this.addLatLonToGribValues(n) : n; } async getWindSpeed(d) { const n = await this.execGribCommandStream( this.getCommandStreamParams({ category: K.Momentum, number: v.WindSpeed }) ); return d != null && d.addLatLon ? this.addLatLonToGribValues(n) : n; } async getWindDirection(d) { const n = await this.execGribCommandStream( this.getCommandStreamParams({ category: K.Momentum, number: v.WindDirection }) ); return d != null && d.addLatLon ? this.addLatLonToGribValues(n) : n; } async getWaveParameters(d) { const n = await this.execGribCommandStream( this.getCommandStreamParams({ category: E.Waves }) ); return d != null && d.addLatLon ? this.addLatLonToGribValues(n) : n; } async getWindParameters(d) { const n = await this.execGribCommandStream( this.getCommandStreamParams({ category: K.Momentum }) ); return d != null && d.addLatLon ? this.addLatLonToGribValues(n) : n; } async getParametersByType(d) { const n = d.keys ? d.keys.join(",") : G, S = await this.execGribCommandStream( this.getCommandStreamParams(d), n ); return d.addLatLon ? this.addLatLonToGribValues(S) : S; } async getMetadata() { return this.execGribCommandStream(void 0, t); } async readToJson(d) { const n = await this.execFullGribDump(); return d != null && d.addLatLon ? this.addLatLonToGribValues(n) : n; } async dispose() { await this.cleanup(); } async cleanup() { if (this.tempFilePath) try { await L.promises.unlink(this.tempFilePath), this.tempFilePath = null; } catch (d) { console.error("Error cleaning up temporary file:", d); } } }; k(H, "DEFAULT_TIMEOUT", 3e4), // 30 seconds k(H, "DEFAULT_RETRIES", 3); let I = H; var Y = /* @__PURE__ */ ((s) => (s[s.CurrentDirection = 0] = "CurrentDirection", s[s.CurrentSpeed = 1] = "CurrentSpeed", s[s.UComponentCurrent = 2] = "UComponentCurrent", s[s.VComponentCurrent = 3] = "VComponentCurrent", s[s.RipCurrentOccurrenceProbability = 4] = "RipCurrentOccurrenceProbability", s[s.EastwardCurrent = 5] = "EastwardCurrent", s[s.NorthwardCurrent = 6] = "NorthwardCurrent", s[s.OceanMixedLayerUVelocity = 192] = "OceanMixedLayerUVelocity", s[s.OceanMixedLayerVVelocity = 193] = "OceanMixedLayerVVelocity", s[s.BarotropicUVelocity = 194] = "BarotropicUVelocity", s[s.BarotropicVVelocity = 195] = "BarotropicVVelocity", s[s.Missing = 255] = "Missing", s))(Y || {}), X = ((s) => (s[s.DegreeTrue = i.DegreeTrue] = "DegreeTrue", s[s.MetersPerSecond = i.MetersPerSecond] = "MetersPerSecond", s[s.Percentage = i.Percentage] = "Percentage", s))(X || {}), Q = /* @__PURE__ */ ((s) => (s[s.IceCover = 0] = "IceCover", s[s.IceThickness = 1] = "IceThickness", s[s.IceDriftDirection = 2] = "IceDriftDirection", s[s.IceDriftSpeed = 3] = "IceDriftSpeed", s[s.UComponentIceDrift = 4] = "UComponentIceDrift", s[s.VComponentIceDrift = 5] = "VComponentIceDrift", s[s.IceGrowthRate = 6] = "IceGrowthRate", s[s.IceDivergence = 7] = "IceDivergence", s[s.IceTemperature = 8] = "IceTemperature", s[s.IceInternalPressure = 9] = "IceInternalPressure", s[s.ZonalVectorIcePressure = 10] = "ZonalVectorIcePressure", s[s.MeridionalVectorIcePressure = 11] = "MeridionalVectorIcePressure", s[s.CompressiveIceStrength = 12] = "CompressiveIceStrength", s[s.SnowTemperatureOverSeaIce = 13] = "SnowTemperatureOverSeaIce", s[s.Albedo = 14] = "Albedo", s[s.SeaIceVolumePerUnitArea = 15] = "SeaIceVolumePerUnitArea", s[s.SnowVolumeOverSeaIcePerUnitArea = 16] = "SnowVolumeOverSeaIcePerUnitArea", s[s.SeaIceHeatContent = 17] = "SeaIceHeatContent", s[s.SnowOverSeaIceHeatContent = 18] = "SnowOverSeaIceHeatContent", s[s.IceFreeboardThickness = 19] = "IceFreeboardThickness", s[s.IceMeltPondFraction = 20] = "IceMeltPondFraction", s[s.IceMeltPondDepth = 21] = "IceMeltPondDepth", s[s.IceMeltPondVolumePerUnitArea = 22] = "IceMeltPondVolumePerUnitArea", s[s.SeaIceFractionTendency = 23] = "SeaIceFractionTendency", s[s.XComponentIceDrift = 24] = "XComponentIceDrift", s[s.YComponentIceDrift = 25] = "YComponentIceDrift", s[s.FreezingMeltingPotential = 27] = "FreezingMeltingPotential", s[s.MeltOnsetDate = 28] = "MeltOnsetDate", s[s.FreezeOnsetDate = 29] = "FreezeOnsetDate", s[s.Missing = 255] = "Missing", s))(Q || {}), U = ((s) => (s[s.Proportion = i.Proportion] = "Proportion", s[s.Meters = i.Meters] = "Meters", s[s.DegreeTrue = i.DegreeTrue] = "DegreeTrue", s[s.MetersPerSecond = i.MetersPerSecond] = "MetersPerSecond", s[s.PerSecond = i.PerSecond] = "PerSecond", s[s.Kelvin = i.Kelvin] = "Kelvin", s[s.PascalMeters = i.PascalMeters] = "PascalMeters", s[s.NewtonsPerMeter = i.NewtonsPerMeter] = "NewtonsPerMeter", s[s.CubicMetersPerSquareMeter = i.CubicMetersPerSquareMeter] = "CubicMetersPerSquareMeter", s[s.JoulesPerSquareMeter = i.JoulesPerSquareMeter] = "JoulesPerSquareMeter", s[s.Fraction = i.Fraction] = "Fraction", s[s.Numeric = i.Numeric] = "Numeric", s[s.WattsPerSquareMeter = i.WattsPerSquareMeter] = "WattsPerSquareMeter", s))(U || {}), h = /* @__PURE__ */ ((s) => (s[s.Meteorological = 0] = "Meteorological", s[s.Hydrological = 1] = "Hydrological", s[s.LandSurface = 2] = "LandSurface", s[s.SatelliteRemoteSensing = 3] = "SatelliteRemoteSensing", s[s.SpaceWeather = 4] = "SpaceWeather", s[s.Oceanographic = 10] = "Oceanographic", s[s.HealthAndSocioeconomic = 20] = "HealthAndSocioeconomic", s[s.Missing = 255] = "Missing", s))(h || {}); const O = (s) => s.parameterCategory === E.Waves && s.parameterNumber === A.SignificantHeightCombined, M = (s) => s.parameterCategory === E.Waves && s.parameterNumber === A.PrimaryWavePeriod; export { h as Discipline, I as EccodesWrapper, i as GribParameterUnits, v as MeteorologicalMomentumParameterNumber, _ as MeteorologicalMomentumParameterUnits, K as MeteorologicalParameterCategory, X as OceanographicCurrentParameterUnits, Y as OceanographicCurrentsParameterNumber, Q as OceanographicIceParameterNumber, U as OceanographicIceParameterUnits, E as OceanographicParameterCategory, A as OceanographicWaveParameterNumber, J as OceanographicWaveParameterUnits, O as isWaveHeight, M as isWavePeriod };