Giter VIP home page Giter VIP logo

nasapower's Introduction

{nasapower}: NASA POWER API Client logo

R-CMD-check codecov DOI Project Status: Active – The project has reached a stable, usable state and is being actively developed. peer-review JOSS CRAN status

POWER data vs {nasapower}

Please note that {nasapower} is NOT the source of NASA POWER data. It is only an API client that allows easy access to the data. {nasapower} does not redistribute the data or provide it in any way, we encourage users to follow the requests of the POWER Project Team and properly acknowledge them for the data rather than citing this package (unless you have actually used it in your work).

When POWER data products are used in a publication, we request the following acknowledgement be included: “The data was obtained from the National Aeronautics and Space Administration (NASA) Langley Research Center (LaRC) Prediction of Worldwide Energy Resource (POWER) Project funded through the NASA Earth Science/Applied Science Program.”

The previous statement that properly cites the POWER data is different than the citation for {nasapower}. To cite this R package, {nasapower}, please use the output from citation(package = "nasapower") and cite both the package manual, which includes the version you used and the paper which refers to the peer-review of the software package as the functionality of the package has changed and will likely change to match the API in the future as necessary.

About {nasapower}

{nasapower} aims to make it quick and easy to automate downloading of the NASA-POWER global meteorology, surface solar energy and climatology data in your R session as a tidy data frame tibble object for analysis and use in modelling or other purposes. POWER (Prediction Of Worldwide Energy Resource) data are freely available for download with varying spatial resolutions dependent on the original data and with several temporal resolutions depending on the POWER parameter and community.

Note that the data are not static and may be replaced with improved data. Please see https://power.larc.nasa.gov/docs/services/ for detailed information in this regard.

Quick start

{nasapower} can easily be installed using the following code.

From CRAN

The stable version is available through CRAN.

install.packages("nasapower")

From GitHub for the version in-development

A development version is available through GitHub.

install.packages("nasapower", repos = "https://ropensci.r-universe.dev")

Example

Fetch daily “ag” community temperature, relative humidity and precipitation for January 1, 1985 for Kingsthorpe, Queensland, Australia.

library("nasapower")
daily_ag <- get_power(
  community = "ag",
  lonlat = c(151.81, -27.48),
  pars = c("RH2M", "T2M", "PRECTOTCORR"),
  dates = "1985-01-01",
  temporal_api = "daily"
)
daily_ag
## NASA/POWER CERES/MERRA2 Native Resolution Daily Data  
##  Dates (month/day/year): 01/01/1985 through 01/01/1985  
##  Location: Latitude  -27.48   Longitude 151.81  
##  Elevation from MERRA-2: Average for 0.5 x 0.625 degree lat/lon region = 442.77 meters 
##  The value for missing source data that cannot be computed or is outside of the sources availability range: NA  
##  Parameter(s):  
##  
##  Parameters: 
##  RH2M            MERRA-2 Relative Humidity at 2 Meters (%) ;
##  T2M             MERRA-2 Temperature at 2 Meters (C) ;
##  PRECTOTCORR     MERRA-2 Precipitation Corrected (mm/day)  
##  
## # A tibble: 1 × 10
##     LON   LAT  YEAR    MM    DD   DOY YYYYMMDD    RH2M   T2M PRECTOTCORR
##   <dbl> <dbl> <dbl> <int> <int> <int> <date>     <dbl> <dbl>       <dbl>
## 1  152. -27.5  1985     1     1     1 1985-01-01  54.7  24.9         0.9

Documentation

More documentation is available in the vignette in your R session, vignette("nasapower") or available online, https://docs.ropensci.org/nasapower/articles/nasapower.html.

Meta

References

https://power.larc.nasa.gov

https://power.larc.nasa.gov/docs/methodology/

nasapower's People

Contributors

adamhsparks avatar femiguez avatar maelle avatar palderman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

nasapower's Issues

Not all parameters can be handled

Trying to run the below code gives an error when the parameter for solar irradiance is defined as "ALL SKY TOA SW DWN"; I get a similar issue with "SI_EF_MIN_OPTIMAL".

In the first case, I get an error message that the "all sky" string is not a valid parameter. In the second, I get an error message that the SI EF min Optimal returns not an energy but an orientation for the panels. In both cases, this is at odds with the documentation on the NASA Power API website. It is possible that these values do not work with the "climatology" temporal average but if that is the case (I have yet to try out others) this is not spelled out clearly in anything I can find.

Thanks!

Session Info
get_power(community = "SSE", pars = c("TS", "ALLSKY_TOA_SW_DWN"), temporal_average = "CLIMATOLOGY", lonlat = c(averagelon, averagelat))

ICASA headers and columns not aligned

Hi! Thanks for the package! When creating the files for DSSAT (ICASA format) headers and columns are not in the alignment that the model requires. In the attached file, the first sequence depicts the working structure, and below the structure generated by create_icasa.
How can I adjust these alignments?
Thanks in advance!
new 1.txt

CSV File Not Created

Repeatedly getting the following error. Nothing seems to be wrong on https://power.larc.nasa.gov/

Error:
A CSV file was not created, this is a server error.
The server may not be responding or is currently responding improperly.
Please check https://power.larc.nasa.gov/ for notifications if
you repeatedly get this error.

Testing with:
power <- get_power(community = "AG",
lonlat = c(-179.5, -89.5),
pars = c("RH2M", "T2M"),
dates = "1985-01-01",
temporal_average = "DAILY")

Simplify querying for climatology data

The arguments for querying Climatology data from POWER can be confusing.

Simplify to use only temporal_average = "CLIMATOLOGY" by setting lonlat = NULL by default and setting lonlat = "GLOBAL" in the get_POWER() function itself when CLIMATOLOGY is detected.

WS2M not accessible through AG community

The code below works, but if I change WS10M for WS2M, it returns an error:

""Error:
You have entered an invalid value for community for the supplied pars. One or more pars are not, available for AG, please check.""

get_power(community = "AG",
                         lonlat = c(-49.554,-20.862, -48.562, -19.851),
                         pars = c("PRECTOT", "T2M_MAX", "T2M_MIN", "T2M", "ALLSKY_SFC_SW_DWN", "RH2M", "T2MDEW", "WS10M"), 
                         dates = c("2018-01-01", paste0(Sys.Date())),
                         temporal_average = "DAILY")

get_power() dates

Error: 18390 is not a valid entry for date. Enter as YYYY-MM-DD.

In response to Error 18390, could you please add functionality for calling a function to define the "dates =" argument in get_power()?

I would like to be able to use lubridate::today() when I call the dates for get_power() so that I can automatically update my get_power() data on a daily basis.

Incorrect dates returned in YYYYMMDD, MM and DD

Example when retrieving data spanning two years.

> cell <- get_cell(lonlat = c(-179.5, -89.5), stdate = "2012-12-30", endate = "2013-01-02")
Downloading: 1.8 kB     

> cell
  YEAR MONTH DAY   YYYYMMDD DOY    LON   LAT    T2M   T2MN   T2MX  RH2M toa_dwn swv_dwn lwv_dwn  DFP2M RAIN
1 2012    12  29 2013-12-29 365 -179.5 -89.5 -28.63 -29.50 -27.74 66.77   47.84   32.40   12.53 -32.83 0.00
2 2012    12  30 2013-12-30 366 -179.5 -89.5 -28.57 -29.62 -27.56 60.89   47.63   39.31   11.02 -33.71 0.00
3 2013    12  30 2012-12-30   1 -179.5 -89.5 -28.10 -29.15 -27.02 64.53   47.81   38.56   10.91 -32.67 0.00
4 2013    12  31 2012-12-31   2 -179.5 -89.5 -27.05 -27.60 -26.29 64.59   46.98   31.54   15.88 -31.66 0.06
  WS10M
1  2.18
2  2.50
3  1.95
4  2.54

Cannot install nasapower

Hi @adamhsparks , when I try to install nasapower, i get the following message and fail to install the package:


library(devtools)
devtools::install_github("adamhsparks/nasapower", build_vignettes = TRUE)

Downloading GitHub repo adamhsparks/nasapower@master
from URL https://api.github.com/repos/adamhsparks/nasapower/zipball/master
Installing nasapower
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save
--no-restore --quiet CMD build
'/private/var/folders/f_/hrv_rbld7w74b42yz8psmmv40000gn/T/RtmpFFlUrZ/devtools808a2043affd/adamhsparks-nasapower-63edbdc'
--no-resave-data --no-manual

  • checking for file ‘/private/var/folders/f_/hrv_rbld7w74b42yz8psmmv40000gn/T/RtmpFFlUrZ/devtools808a2043affd/adamhsparks-nasapower-63edbdc/DESCRIPTION’ ... OK
  • preparing ‘nasapower’:
  • checking DESCRIPTION meta-information ... OK
  • installing the package to build vignettes
  • creating vignettes ... ERROR
    Quitting from lines 66-74 (use-case.Rmd)
    Error: processing vignette 'use-case.Rmd' failed with diagnostics:
    Not Found (HTTP 404).
    Execution halted
    Installation failed: Command failed (1)

Do you have any idea what is going wrong? I've installed devtools already.

Extended documentation is out of date

The "nasapower" vignette is out of date and should be updated to reflect new functionality and how to create spatial objects using the currently provided functionality.

Error when running example

@adamhsparks I was trying to run the second example but got this error:

get_cell(lonlat = c(-179.5, -89.5), endate = "1983-01-02", vars = "WS10M")

Error in curl::curl_fetch_memory(url, handle = handle) :
The POWER website does not appear to be responding.
Please try again later.

Power Data files.

Can't download data files from POWER Data Acces Viewer, i am for a few days now and getting this error "Unable to access data at this time, please check back soon.". I am using the API in python now but is very slow and need faster access to the data.

Thanks.

Missing data is -99

But maybe -999 as well?

Just account for possibility of both being in the data as currently it's set to -999.

v1.0.5 is exactly same as v1.0.4

Typo locally caused v1.0.5 to be exactly the same as v1.0.4

Also missed out on support for WS2M_MIN, WS2M_MAX and WS2M_RANGE in the release.

Error when fetching SI_EF_OPTIMAL and some other parameters

Hello,
I cannot make 'get_power' working for some parameters like "SI_EF_OPTIMAL". They can be accessed using NASA's web interface:
https://power.larc.nasa.gov/downloads/POWER_SinglePoint_Climatology_033d04N_093d00E_8ddb2015.txt
which creates this order:
https://power.larc.nasa.gov/cgi-bin/v1/DataAccess.py?&request=execute&identifier=SinglePoint&parameters=SI_EF_TILTED_SURFACE&userCommunity=SSE&tempAverage=CLIMATOLOGY&outputList=ASCII&lat=33.4000&lon=93.0000
Here is the code I use:

sol_daily_BJ <- get_power(community = "SSE",
                          lonlat = c(93, 33.4),
                          pars = c("SI_EF_OPTIMAL"),
                          temporal_average = "CLIMATOLOGY"
)

Which returns:
"Error:
Something went wrong with the query, no data were returned.
Please see https://power.larc.nasa.gov for potential server issues."
I'm not sure if this is the package or the POWER issue, or I'm just writing it wrong way.
Here is my system info:

devtools::session_info()

  • Session info --------------------------------------------------------------------
    setting value
    version R version 3.5.3 (2019-03-11)
    os Windows >= 8 x64
    system x86_64, mingw32
    ui RStudio
    language (EN)
    collate English_United States.1252
    ctype English_United States.1252
    tz America/New_York
    date 2019-04-05

Required arguments should come before optional in function calls

@sckott wrote,

Also about get_power. it's not a good idea to have a required parameter (w/o a default) after a non-required parameter. that is, you have function(community, lonlat, pars, dates = NULL, temporal_average), whereas function(community, lonlat, pars, temporal_average, dates = NULL) would make more sense b/c all required paramters are first, then the last is optional

NASA POWER Server not responding

If the server/web-page is not responding the package will continuously try to retrieve the data for several minutes until failing.

Add function to check server response before requesting data.

get_region() returns only first date value

Using get_region() with multiple dates will return only the first date, e.g.,

oz <- get_region(lonlat = c(112.91972, 159.256088, -55.11694, -9.221099),
                    stdate = "2017-1-1", endate = "2017-1-2")

will only return data for Jan. 1 for Australia.

Migrate to Web Services Portal Version 2 by 2021-07-01

The POWER team are migrating to a new API by 2021-07-01, https://power.larc.nasa.gov/beta/docs/services/api/

v4.0 will take advantage of this new functionality.

  • Implement new API V2 calls
  • Implement new functions to take advantage of the new manager API providing information on parameters
  • Consolidate, standardise and optimise functions that may be shared between get_power() and the new query_parameters()
  • Write tests for new and revised functions
  • Update vignette to reflect new functionality of nasapower and the POWER API V2
  • Check functionality against the new API, e.g. rate limits as reported in #52 (comment)

Error while using R to access the API

I just followed the example provided in the package to access daily data, see below.

library(nasapower)
daily_single_ag <- get_power(community = "AG",
                             lonlat = c(151.81, -27.48),
                             pars = c("RH2M", "T2M", "PRECTOT"),
                             dates = c("1985-01-01", "1985-01-31"),
                             temporal_average = "DAILY"
)

daily_single_ag

It through the error below

Error: 
Something went wrong with the query, no data were returned. Please see <https://power.larc.nasa.gov> for potential server issues.

New link for the parameters.json

Hello,

I am a developer with the NASA POWER Project and would like to let you know that there is a new link for the parameters.json file. We had to change hosing environments and that required some changes to the URL's structure.

Please use the following link in your application:

Replacing:

Other Links:

Calls to the API are returning an error

Calls to the API all day are returning the error below:

Error: Something went wrong with the query, no data were returned. Please see <https://power.larc.nasa.gov> for potential server issues.

Add function to get POWER data and create APSIM .met file

Use the APSIM package to generate a .met file for use in APSIM using POWER data.

e.g. create_met <- (years = NULL, latlon = NULL) and the function generates a full APSIM .met file object based only on date(s) and location(s) with appropriate data.

Error when fetching CLIMATOLOGY for single point

x <- get_power(community = "SSE",
+                           lonlat = c(93, 33.4),
+                           pars = "T2M",
+                           temporal_average = "CLIMATOLOGY"
+ )
Warning: 2 parsing failures.
row col  expected     actual                                                                           file
  2  -- 1 columns 16 columns '/var/folders/_x/gqh2xrvn4qb0qs5d8795n8vr0000gn/T//RtmpbbGDUb/power_data_file'
  3  -- 1 columns 16 columns '/var/folders/_x/gqh2xrvn4qb0qs5d8795n8vr0000gn/T//RtmpbbGDUb/power_data_file'

Error: Positive column indexes in `[` must match number of columns:
* `.data` has 1 columns
* Position 1 equals 2
* Position 3 equals 3
* Position 4 equals 2
Call `rlang::last_error()` to see a backtrace

Error in curl::curl_fetch_memory

I am trying to run these lines of code (provided as example on readme.md).

if (!require(devtools)) {
  install.packages("devtools")
}
devtools::install_github("ropensci/nasapower",
                         build_vignettes = TRUE)

#install.packages("nasapower",dep = T)
library(nasapower)

daily_ag <- get_power(community = "AG",
                      lonlat = c(151.81, -27.48),
                      pars = c("RH2M", "T2M", "PRECTOT"),
                      dates = "1985-01-01",
                      temporal_average = "DAILY")

However, after a minute (or more) of waiting, i click on the stop button and the following returns:

Error in curl::curl_fetch_memory(x$url$url, handle = x$url$handle) :
Operation was aborted by an application callback

I have been running these same lines of code before and it was working flawlessly, but since yesterday i get these error returns. There is any server instability these days?

Add csvy support for exported data?

Thomas Leeper has created a package to read/write CSVY files (CSV with a YAML header).

This could be useful for storing the metadata that the POWER API serves and is currently only displayed in the header information but not exported from the R session unless using a .Rds or other R file to save the data.

https://github.com/leeper/csvy

DOY column: dates and formatting

The below code gives the error that the DOY column (day of year?) is uninitialised, but I do not see how the date could be any differently formatted.

``

oceanic2 <- nasapower::get_power(community = "SSE", lonlat = c(3.9, 52.5), pars = "T2M", dates =c("1999-01-01", "2000-01-01"), temporal_average = "DAILY")

Error in $<-.data.frame(*tmp*, "DOY", value = integer(0)) :
replacement has 0 rows, data has 366
In addition: Warning message:
Unknown or uninitialised column: 'DOY'.

Validate user vars input

Raised by @sckott

get_cell(lonlat = c(-179.5, -89.5), vars = 'asdfasdf')
#> Error in `[.data.frame`(NASA, , c(refcols, setdiff(names(NASA), refcols))) :
#>  undefined columns selected

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.