Giter Site home page Giter Site logo

evolecolgroup / pastclim Goto Github PK

View Code? Open in Web Editor NEW
25.0 1.0 0.0 25.33 MB

An R package providing helper functions to interact with timeseries of worldwide climate reconstructions

Home Page: https://evolecolgroup.github.io/pastclim/

License: Creative Commons Attribution 4.0 International

R 94.63% Shell 5.37%
paleoclimate r

pastclim's People

Contributors

dramanica avatar mikleonardi 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

Watchers

 avatar

pastclim's Issues

biome value is float when using nn_interpol

Observed behaviour: biome becomes a float when nn_interpol is used on samples for which no climate is available

Example:
floating_biomes.csv

library(pastclim)

# read in data
wolve <- read.csv("./floating_biomes.csv", header = T, sep = ",")

# extract climate data for sample locations
climate_locs <- location_slice(x=wolve[,c("latitude","longitude")], time_bp=0, bio_variables="biome", dataset="Beyer2020")
head(climate_locs)
  latitude longitude time_bp time_bp_slice    biome
1 64.48000 -162.1200       0             0 18.66667
2 64.48000 -162.1200       0             0 18.66667
3 64.48000 -162.1200       0             0 18.66667
4 64.48000 -162.1200       0             0 18.66667
5 59.60000   26.2000       0             0  7.75000
6 70.00499 -144.7539       0             0 22.33333

When nn_interpol is disabled, NA is returned:

climate_locs_no_interpol <- location_slice(x=wolve[,c("latitude","longitude")], time_bp=0, bio_variables="biome", dataset="Beyer2020", nn_interpol = FALSE)
head(climate_locs_no_interpol)
  latitude longitude time_bp time_bp_slice biome
1 64.48000 -162.1200       0             0    NA
2 64.48000 -162.1200       0             0    NA
3 64.48000 -162.1200       0             0    NA
4 64.48000 -162.1200       0             0    NA
5 59.60000   26.2000       0             0    NA
6 70.00499 -144.7539       0             0    NA

Problem appears to be with samples in the sea rather than samples that are under ice although this may be coincidental:
image

# plot map with database points, biome, present day
climate_present <- region_slice( time_bp = 0, bio_variables = c("biome"), dataset = "Beyer2020", ext=c(-180,180,30,85))

# extract ice masks and convert to polygons
ice_mask <- get_ice_mask(0, dataset = "Beyer2020")
ice_mask_vect <- as.polygons(ice_mask)

# extract locations from database
locations_vect <- vect(wolve, geom=c("longitude", "latitude"))

# plot
terra::plot(climate_present$biome, 
fun=function() {
points(locations_vect, pch=21, col="black", bg="red", lwd=0.5, cex=1) 
polys(ice_mask_vect, col="grey", lwd=0.5)})

Can't identidy variable names in location_slice

Hi,

First let me congratulate you on creating such a valuable resource. This package is exactly what I have been looking for and I think it is going to be hugely useful for me.

I am just learning the ropes of this package and have hit a roadblock. I think perhaps this might be an probably with a dependency package, or perhaps I have not installed things correctly, but I have run out of things to try and was hoping you could offer some pointers.

I am walking through the vignette code* but when I get the location_slice function, I get errors saying the variables I would like to use aren't available, with some alternatives offered. When I use the alternative names, I get the same message with the expected variable names offered as alternatives.

*I also couldn't compile the vignettes during installation which might stem from the same problem

I used this code, with the following errors:

library(pastclim)

# data installation
# set_data_path(path_to_nc = "~/Documents/projects/pastclim_data/")

df = structure(list(Language = c("Kimaghama ", "Riantana", "Ndom ", "Mombum (Komolom)", "Koneraw ", "Marori"), 
                    longitude = c(138.4520445, 138.4889957, 137.998408, 138.7896383, 138.3278637, 140.5149879), 
                    latitude = c(-7.899618841, -7.526408993, -7.991955007, -8.286129011, -8.327860384, -8.538172179)), 
               row.names = c(NA, 6L), 
               class = "data.frame")
df$time_bp1 = -10000

climate_60kya = location_slice(x = df[, c("longitude", "latitude")],
                               time_bp = df$time_bp1, 
                               bio_variables = c("bio01", "bio12"),
                               dataset = "Example", 
                               nn_interpol = FALSE
                               )
# Error: [rast] BIO1 not found. Choose one of:
# //BIO1, //BIO10, //BIO12, //biome

climate_60kya = location_slice(x = df[, c("longitude", "latitude")],
                               time_bp = df$time_bp1, 
                               bio_variables = c("//BIO1", "//BIO12"),
                               dataset = "Example", 
                               nn_interpol = FALSE)
# Error in check_available_variable(variable, dataset) : 
#  //BIO1, //BIO12 not available for Example; available variables are bio01, bio10, bio12, biome

Stepping through the location_slice function, the error comes from the following line:

climate_brick <- terra::rast(this_file, subds = this_var_nc)
# Error: [rast] BIO01 not found. Choose one of:
# //BIO1, //BIO10, //BIO12, //biome

Remove the subsetting argument allows the function to run, but with a warning:

climate_brick <- terra::rast("~/Documents/projects/pastclim_data//example_climate.nc")
Warning message:
[rast] unknown extent

My conclusion then is there is either something missing from the .nc file or something else is going on. Since I get the same errors for the Beyer2020 dataset, I would guess it is something else. What could I try to figure out what is going wrong?

I am running MacOS Monterey with Apple M1 Chip.

terra interface

In pastclim::time_bp you have

if (x@ptr$timestep!="years"){

That breaks with the development version of terra. The @ptr$ methods are not really safe for use in other packages. Can you use the "official" interface instead? In this case that could be:

if  (timeInfo(x)$step != "years"){

Thanks!

Variable descriptions for each dataset

Hi,

Is there a table available that describes the variables within each dataset? Like with table 1 in the pre-print, but for all variables, and which we could access from within the package? (for plotting titles etc.)

For example: what is mo_npp_[month]?

pastclim not compatible with the latest terra on CRAN 1.6-41

terra has changed the way it reads times from netcdf file. This change impacts a number of the functions in pastclim. We will soon update pastclim, but don't update terra for the moment. Use the commands on the website to downgrade terra if you have an udpated version.

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.