Closed milonbrri closed 3 years ago
Thanks @milonbrri.
With regard to your request:
I will be happy if you provide me the code with sample file extract the NetCDF files for Bangladesh.
If you already have downloaded NetCDF files for Bangladesh from CMIP6, and you only want to extract some data from them, not creating an EnergyPluw EPW file, you can achieve that using the code below (Note the code below uses unexported functions which are subject to change):
# file path of your downloaded NetCDF file
file <- "My/NetCDF/file/path"
# match data points using latitude and longitude for Bangladesh
coord <- epwshiftr:::match_nc_coord(file, 24, 90)
# extract data from your NetCDF file
data <- epwshiftr:::get_nc_data(file, coord$lat, coord$lon, years = 2100)
The descriptions on the format of extracted data can be found here
epwshiftr heavily relies on an index file to store all the metadata of NetCDF files. It builds an index file using init_cmip6_index()
by querying the database of ESGF, and matches downloaded NetCDF files using summary_database()
. Currently, there is no direct way to build an index from existing files. This means that you have to build your own index. You can achieve it by doing either of the following:
init_cmip6_index(activity = , variable = , frequency = , experiment = , ...)
to build the index, and run summary_database()
to match them. A full example has been given in the READMEset_cmip6_index()
.Besides the index, you have to give a baseline EPW file for Bangladesh if you haven't. EnergyPlus website did not give a weather file for Bangladesh, but you can find one from other resources, e.g. https://www.ladybug.tools/epwmap/.
Once you have the index and baseline EPW file, you can just follow the steps in the README to create your future EPW files.
library("epwshiftr")
library("remotes")
options(epwshiftr.dir = tempdir())
options(epwshiftr.verbose = TRUE)
# get CMIP6 data nodes
idx <- init_cmip6_index(
# only consider ScenarioMIP activity
activity = "CMIP",
# specify dry-bulb temperature and relative humidity
variable = c("pr"),
# specify report frequent
frequency = "day",
# specify experiment name
experiment = c("ssp126"),
# specify GCM name
source = "BCC-CSM2-MR",
# specify variant,
variant = "r1i1p1f1",
# specify years of interest
years = c(2015,2070),
# save to data dictionary
save = TRUE
)
Querying CMIP6 Dataset Information No matched data. Please examine the actual response using 'attr(x, "response")'.
Why??
This is because ssp126
is only available for ScenarioMIP
activity, not available for CMIP
activity.
idx <- init_cmip6_index(
# only consider ScenarioMIP activity
activity = "ScenarioMIP", # <----- Here
# specify dry-bulb temperature and relative humidity
variable = c("pr"),
# specify report frequent
frequency = "day",
# specify experiment name
experiment = c("ssp126"),
# specify GCM name
source = "BCC-CSM2-MR",
# specify variant,
variant = "r1i1p1f1",
# specify years of interest
years = c(2015,2070),
# save to data dictionary
save = TRUE
)
Thanks a lot for your quick answer. I understood now. However, In the case of the historical data set, activity ="..........", ?????
There are lots of activities in the CMIP6 program, which are quite complicated. I am not familiar with them and I did not know if there are historical data sets.
You may first go to https://esgf-node.llnl.gov/search/cmip6/ to explore if there are any data that meets your needs and them put those search keywords back to init_cmip6_index()
to get the output index.
Hello Jia! I am here!! I need an example of code as converse in Email earlier
Regards ZZaman