UNPKG

s2-tools

Version:

A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.

112 lines 5.41 kB
import type { FeatureIterator, Reader, ReaderInputs } from '..'; import type { Grib2ProductDefinition, Grib2Sections } from './sections'; import type { Properties, VectorFeature, VectorMultiPointGeometry } from '../../geometry'; export * from './sections'; export type { Grib2ProductDefinition, getGrib2Template4 } from './sections'; /** GFS sources available for download */ export type Grib2GFSSource = 'aws' | 'ftpprd' | 'nomads' | 'google' | 'azure' | string; /** * GFS products available for download * `pgrb2.0p25` - common fields, 0.25 degree resolution * `pgrb2.0p50` - common fields, 0.50 degree resolution * `pgrb2.1p00` - common fields, 1.00 degree resolution * `pgrb2b.0p25` - uncommon fields, 0.25 degree resolution * `pgrb2b.0p50` - uncommon fields, 0.50 degree resolution * `pgrb2b.1p00` - uncommon fields, 1.00 degree resolution * `pgrb2full.0p50` - combined grids of 0.50 resolution * `sfluxgrb` - surface flux fields, T1534 Semi-Lagrangian grid * `goesimpgrb2.0p25` - 0.50 degree resolution */ export type Grib2GFSProduct = 'pgrb2.0p25' | 'pgrb2.0p50' | 'pgrb2.1p00' | 'pgrb2b.0p25' | 'pgrb2b.0p50' | 'pgrb2b.1p00' | 'pgrb2full.0p50' | 'sfluxgrb' | 'goesimpgrb2.0p25'; /** * Fetch GFS data. * You can find some data to reference what's available [here](https://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/). * An example of what variable data means can be found [here](https://www.nco.ncep.noaa.gov/pmb/products/gfs/gfs.t00z.pgrb2.0p50.f000.shtml). * @param source - The source of the data, `aws` | `ftpprd` | `nomads` | `google` | `azure` | or a user provided url * @param product - which product to fetch * @param year - The year to fetch given a 4 digit year * @param month - The month to fetch given a 2 digit month 01 is January and 12 is December * @param day - The day to fetch given a 2 digit day, e.g. '01' or '31' * @param hour - The forecast hour with 2 digits often in increments of 6 up to 18, e.g. '00' or '12' * @param forecast - The forecast hour with 3 digits often in increments of 3 up to 384, e.g. '000' or '003' * @param filters - The filters to apply by filtering lines in the .idx file * @returns - A GRIB2Reader of the specific sections */ export declare function fetchGFSAtmos(source: Grib2GFSSource, product: Grib2GFSProduct, year: string, month: string, day: string, hour: '00' | '06' | '12' | '18', forecast?: string, filters?: string[]): Promise<GRIB2Reader>; /** Description of a section in the GRIB2 file */ export interface SectionLocations { /** Start/offset of section */ start: number; /** If missing, assume the end is the end of the file */ end?: number; /** The entire line detailing the section */ line: string; /** The name of the filter */ name: string; } /** * Parse the .idx file for GRIB2 section details using a URL * @param url - The URL of the .idx file * @param filters - The filters to apply * @param offsetPosition - The position of the offset in the ":" sequence * @returns - An array of SectionLocations */ export declare function parsedIDXFromURL(url: string, filters: string[], offsetPosition?: number): Promise<SectionLocations[]>; /** * Parse the .idx file for GRIB2 section details * @param data - The contents of the .idx file * @param filters - The filters to apply * @param offsetPosition - The position of the offset in the ":" sequence * @returns - An array of SectionLocations */ export declare function parseIDX(data: string, filters: string[], offsetPosition?: number): SectionLocations[]; /** * # GRIB2 Reader * * ## Description * * This class reads a GRIB2 file and returns a list of GRIB2 products. * Implements the {@link FeatureIterator} interface. * * ## Usage * * ### The recommended way to parse grib files is to filter out what you want: * ```ts * // pull .idx file FIRST and filter the ones you want * const filters = [':DZDT:0.01 mb:', ':TMP:0.4 mb:', ':ABSV:0.4 mb:anl:']; * const idxs = await parsedIDXFromURL(`${link}.idx`, filters); * // now bulid the reader * const gribReader = await GRIB2Reader.fromIDX(link, idxs); * * for await (const feature of gribReader) { * console.log(feature); * } * ``` * * ### Parsing the entire grib file: * ``` * const gribReader = new GRIB2Reader(link); * ``` */ export declare class GRIB2Reader implements FeatureIterator<Grib2ProductDefinition[]> { private idxs?; packets: Grib2Sections[]; /** * @param readers - Reader(s) for entire GRIB file. If array, its grib chunks, otherwise it will be the entire file * @param idxs - The list of section locations we will be parsing */ constructor(readers: ReaderInputs | Reader[], idxs?: SectionLocations[] | undefined); /** * Create a GRIB2Reader from a .idx file * @param source - Either the http path to the .idx file or the entire GRIB file * @param idxs - The parsed .idx file with the locations of each section * @returns A GRIB2Reader of the specific sections */ static fromIDX(source: string | Reader, idxs: SectionLocations[]): Promise<GRIB2Reader>; /** * Iterate through each packet and add their products to the geometry * @yields {VectorFeature} */ [Symbol.asyncIterator](): AsyncGenerator<VectorFeature<Grib2ProductDefinition[], Record<string, number>, Properties, VectorMultiPointGeometry>>; } //# sourceMappingURL=index.d.ts.map