Skip to content

Commit fd767c7

Browse files
authored
Merge pull request #1 from moritzshore/dev
Prepared for first release
2 parents d04feb3 + c4c435d commit fd767c7

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

NAMESPACE

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ importFrom(ncdf4,nc_open)
1515
importFrom(ncdf4,ncvar_get)
1616
importFrom(purrr,map)
1717
importFrom(readr,write_csv)
18+
importFrom(sf,read_sf)
1819
importFrom(sf,st_as_sf)
1920
importFrom(sf,st_bbox)
2021
importFrom(sf,st_buffer)

R/metnorenal3.R

+8-5
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@
99
# server status:
1010
# https://status.met.no/
1111

12-
# main function ##################
1312

1413
#' Download data from the metno renanalysis project
1514
#'
1615
#' This function accesses the THREDDS server of met.no with download queries
1716
#' formatted from user input. (to be expanded upon)
1817
#'
1918
#' @param area (string) path to geo-referenced shapefile covering the desired area
20-
#' @param directory (string) path to desired working directory
19+
#' @param directory (string) path to desired working directory (default: working directory)
2120
#' @param fromdate (string) date and time for start of time series (ie. "2012-09-01 10:00:00")
2221
#' @param todate (string) date and time for end of time series (ie. "2013-09-01 10:00:00")
2322
#' @param area_buffer desired buffer around the provided shapefile (in meters, default 1500)
@@ -41,17 +40,21 @@
4140
#'
4241
get_metno_reanalysis3 <-
4342
function(area,
44-
directory,
43+
directory = NULL,
4544
fromdate = "2012-09-01 10:00:00",
4645
todate = "2012-09-01 20:00:00",
4746
area_buffer = 1500,
4847
preview = TRUE
4948
){
5049

50+
if(directory %>% is.null()){
51+
directory <- getwd()
52+
}
53+
5154
# load in the shape file
5255
area <- sf::read_sf(area)
5356

54-
# supporting functions
57+
# supporting functions ----
5558
nc_open_retry <- function(link) {
5659

5760
nc_file <- tryCatch(expr = {ncdf4::nc_open(link)},
@@ -537,7 +540,7 @@ get_metno_reanalysis3 <-
537540
}
538541

539542

540-
### START MAIN FUNCTION
543+
### START MAIN FUNCTION ----
541544

542545
# Add stop if nots (date wrong order)
543546

README.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
This R package hosts a variety of functions for NIBIO DMN Hydrology and Water Environment. If any bugs or problems are encountered, please open a new [issue](https://github.com/moritzshore/miljotools/issues) and we will attempt to resolve it.
44

5+
**Table of contents**
6+
7+
1. [Installing miljotools]
8+
9+
2. [MET Nordic Reanalysis Dataset]
10+
11+
3. [Add your own functions/code/workflows]
12+
513
## Installing miljotools
614

715
You can install and load `miljotools` from the GitHub repository using the following command:
@@ -35,7 +43,7 @@ To access the data for a specific region of the Nordics, you need to provide the
3543

3644
1. A path to a geo-referenced [shapefile](https://doc.arcgis.com/en/arcgis-online/reference/shapefiles.htm) (single polygon) of the desired area
3745

38-
2. A directory where you would like to save the data.
46+
2. A directory where you would like to save the data (default: working directory)
3947

4048
3. A starting date and time
4149

@@ -60,4 +68,6 @@ As output you will receive a seperate .csv file for each grid point. This .csv f
6068

6169
**Note:** Currently, this function must request the data from met.no server on an hour-basis. This means that for each year to download, 8760 requests must be made to the server. This is rather slow, and as such the download can take quite a few hours. We are working with met.no to improve this situation.
6270

63-
###
71+
## Add your own functions/code/workflows
72+
73+
If you have a function / code / workflow / etc. which you would like to add to this package, please contact the maintainer for developer access.

man/get_metno_reanalysis3.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)