npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dwd-grib-helper

v0.3.2

Published

Helper package to access grib files provided by DWD and downloaded by data crawler

Downloads

22

Readme

dwd-grib-helper

dwd-grib-helper is a tiny helper package to extract timeseries data from grib files that have been downloaded by the dwd_data_crawler service.

The package is being developed and maintained by the Chair of Automation and Energy Systems at the Saarland University.

LICENSE

dwd-grib-helper is released under the ISC license.

Installation

$ npm install dwd-grib-helper

Usage

The dwd-grib-helper package exposes two functions

deriveGrib2DirectoryPath

  • purpose: derive the path to a specific directory holding .grib2.lz4 files (lz4 compressed grib2 files)
  • arguments:
      1. (String): path to the grib directory within the folder structure generated by dwd_data_crawler
      1. (Number): reference timestamp of the forecast run as UNIX EPOCH in ms resolution

extractTimeseriesDataFromGrib2Directory

  • purpose: asynchronously extract a timeseries from a given directory
  • arguments:
    1. (String): path to the directory holding the .grib2.lz4 files (lz4 compressed grib2 files) of a single foreacast run for a single
    2. (Object): location in terms of latitude and longitude of the point of interest (will automatically be rounded to grid accuracy)
  • returns (Object):
    • location: the location in terms of latitude and longitude of the actual location on the grid, stored in the grib2 files, that has been used to exract the timeseries data.
    • timeseriesData: the actual timeseries data (in terms of raw data) as Array of Object. Each Object in the Array has two attributes:
      • timestamp (Number): the timestamp of as UNIX EPOCH in ms resolution
      • value (Number): the value (invalid values are encoded as null)

Full example

const {
  deriveGrib2DirectoryPath,
  extractTimeseriesDataFromGrib2Directory
} = require('dwd-grib-helper')

async function main () {

  // derive path of directory where data is stored
  const directoryPath = deriveGrib2DirectoryPath(
    '/mnt/data/weather/cosmo-d2/grib', // must be adopted to the correct path
    1529377200000,                     // UNIX EPOCH in ms resolution for 2018-06-19 03:00 UTC
    't_2m'                             // id for temperature of air in 2m height above ground
  )

  // load and extrat timeseries data from directory
  let ts
  try {
    ts = await extractTimeseriesDataFromGrib2Directory(
      directoryPath,
      {                 // location of Saarland University
        lat: 49.256138, // 49.256138 °N
        lon: 7.041273   //  7.041273 °E
      }
    )
  } catch (error) {
    console.error('something went wrong while loading the timeseries')
    console.error(error)
    return
  }
  
  console.log('data has been loaded for location: ' + ts.location.lat ' °N, ' + ts.location.lon + '°E')
  console.log(ts.timeseriesData)
}

main()