Code Monkey home page Code Monkey logo

metnodi's Introduction

metnodi

The goal of metnodi is to provide an interface to the met Nordic data (metnodi stands for met Nordic data interface). For a detailed description of this data and links to the original source please see the met Nordic github page. Currently, the package merely simplifies the download of targeted weather data from thredds.met.no, and saves this data in convenient netcdf format. It supports downloading for target locations (finding the nearest neighbor gridcells of the MET Nordic data), or a rectangular area (in lon/lat). Moreover, downloads are pooled in time into either daily-, monthly-, yearly- or a single file, depending on the size of the downloaded area. This format is more convenient to work with than the original format, which is a single netcdf per hour. The package also has functions for plotting and loading the downloaded data.

Installation

You can install the development version of metnodi from GitHub with:

# install.packages("devtools")
devtools::install_github("NorskRegnesentral/metnodi")

Example

This is a basic example which shows you how to download data:

library(metnodi)

### downloading a rectangular area ###

# area around Oslo
lon_min = 8
lon_max = 12
lat_min = 58
lat_max = 62

time_start = "2024-01-01"
time_end = "2024-01-03"

# download all available weather variables in this area and store it in a temporary file:

download_metno_analysis_rect(file_out = 'oslo_weather_202401.nc', 
                             out_dir = tempdir(),
                             bbox = c(lon_min,lat_min,lon_max,lat_max),
                             time_start = time_start,
                             time_end = time_end)

### downloading data for specific locations ###

# Here, we only download precipitation. Use weather_variables() to see the names of all available weather variables 

# some locations in the area around Oslo:
coords = data.table(lon = runif(50,min = lon_min, max = lon_max),
                    lat = runif(50,min = lat_min, max = lat_max))

download_metno_analysis_nn(file_out = 'oslo_weather_202401.nc', 
                           out_dir = tempdir(),
                           coords = coords,
                           time_start = time_start,
                           time_end = time_end,
                           vars = 'precipitation_amount')


### plotting ###

# here we plot the first time-slice of precipitation downloaded above:

st = read_stars_metno(paste0(tempdir(),'/oslo_weather_202401.nc'),var = 'precipitation_amount')
pp = gmaps_plot(st) + ggplot2::scale_fill_gradient(name = 'mm',low = 'white',high = 'blue')
plot(pp)

metnodi's People

Watchers

Pierre Lison avatar Thordis L. Thorarinsdottir avatar  avatar John Enok Vollestad avatar

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.