Code Monkey home page Code Monkey logo

arso-rainfall-intensity's Introduction

arso-rainfall-intensity

  • This project is written in typescript 3.9, but you can use its transpiled javascript built which targets ES2015.
  • Built includes typings and declaration map (for debugging), so if your IDE is good enough you'll get module type hints working with JS.

Documentation by example:

    const fs = require('fs');
    const { ArsoHttpApi, ArsoProjection } = require('arso-rainfall-intensity');
    
    // returns snapshots from oldest to newest (moving window 2 hours span, with sample rate of 5 mins) 
    const latestSnapshots = await ArsoHttpApi.fetchLatestRadarSnapshotsTimeline();
    const mostRecentSnapshot = latestSnapshots[latestSnapshots.length - 1];
    console.log('snapshot time:', mostRecentSnapshot.dateTime);
    // fetch the radar image
    const radarImageBuffer = await mostRecentSnapshot.fetchRadarImageBuffer();
    // for debug view we can save it on disk
    fs.writeFileSync('latest.png', radarImageBuffer);

    const projection = new ArsoProjection();
    // initialize the projection from buffer, striping all unknown pixel colors seen in image.
    // developer must ensure that the image buffer is from the arso api (if he's not using the given api wrapper in this module).
    projection.loadImageFromBuffer(radarImageBuffer);

    // loadImageFromBuffer strips all unknown pixels and sets them to 0,0,0,0 - rgba (For example: removing the red border around the borders of radar image)
    fs.writeFileSync('latest-processed.png', projection.getImageBuffer());

    // returns rgba pixel values at given location in picture 
    // Note 0,0 is top left of the picture.
    projection.getPixelInfo({ x: 69, y: 69 });

    // returns result object that inteprets pixel values 
    // * result.value = integer value of dBZ (range of 0 - 57) - decibel relative to Z https://en.wikipedia.org/wiki/DBZ_(meteorology)
    // * result.group = integer range of 0 - 4, gruping by near values of .value [0 dBZ = 0, 15-24 dBZ = 1, 27-36 dBZ = 2, 39-48 dBZ = 3,  51-57 dBZ = 4]
    // * result.pixel = rgb value of the pixel (ignoring alpha)
    projection.getPixelRadarValue({ x: 69, y: 69 });

    // because radar image is bad at the bounds (preprocessing is removing all pixels outside)
    // you can check if point is inside the boundings.
    projection.isPixelInInterestBounds({ x: 69, y: 69 });
    // instead of using the above method, bounds can be accessed from the following property.
    projection.interestPixelBounds

    // Given lng lat, returns the pixel position in radar image.
    projection.projectDegreeUnitToImagePixel({ x: LNG_VALUE, y: LAT_VALUE });

    // Given lng lat, returns meter position
    projection.projectDegrees2MeterUnits({ x: LNG_VALUE, y: LAT_VALUE });

    // Given pixel location, returns the lng lat postion
    projection.projectImagePixelToDegreeUnit({ x: 69, y: 69 });

    // Given pixel location, returns the meter postion
    projection.projectImagePixelToMeterUnit({ x: 69, y: 69 });

    // Given meter location, returns the pixel position
    projection.projectMeterUnitToImagePixel({ x: METER_LNG_VALUE, y: METER_LAT_VALUE });

    // Given meter locatiom, returns the lng lat position
    projection.projectMetersToDegreeUnits({ x: METER_LNG_VALUE, y: METER_LAT_VALUE });

arso-rainfall-intensity's People

Contributors

dkorosec avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

amadejkrepek

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.