SkillAgentSearch skills...

RSQM

r package doing Simple Quantile Mapping downscaling technique.

Install / Use

/learn @PablitoCho/RSQM
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

rSQM

r package doing Simple Quantile Mapping downscaling technique.

This version did not pass CRAN check, the final(published) version is now on CRAN repository.

See https://cran.r-project.org/web/packages/rSQM/index.html

Since the workflow is kind of complicated(Don't worry. It's not hard.), this vignette shows you how to run the rSQM package to do a downscaling process with CMIP5(Coupled model intercomparison project 5) data and observation data. If you want to see more about the data used in this package and APEC climate center, visit our website http://www.apcc21.org.

Arguments yaml file.

This procedure needs many datasets which tend to be large. Therefore, It is recommended to use meticulous directory structure, such as, project directory, observation directory, CMIP5 directory and so on. Before explaining those directories, see below yaml formatted file.

prjdir: D:/"Your project name"/foo
dbdir: D:/"Your project name"/Database
stndir: $(prjdir)/Observed/"station or regional name recommened"
bnddir: $(prjdir)/gis-boundary
qmapdir: $(prjdir)/Downscale/SQM
syear_obs: 1976     # Starting year of observed data
eyear_obs: 2005     # Ending year of observed data
syear_his: 1976     # Starting year of historical period (GCM)
eyear_his: 2005     # Ending year of historical period (GCM)
syear_scn:         
  - 2010
  - 2040
eyear_scn:
  - 2039
  - 2069
SimAll: FALSE       # Option for simulation all (GCM model, Variable, RCPs) combinations
ModelNames:
  - bcc-csm1-1-m    # Beijing Climate Center,  China Meteorological Administration (128x64)
  - CanESM2         # Canadian Centre for Climate Modelling and Analysis (128x64)
  - CMCC-CMS        # Centro Euro-Mediterraneo per I Cambiamenti Climatici (192x96)
  - CSIRO-Mk3-6-0   # Commonwealth Scientific and Industrial Research Organisation in  collaboration with the Queensland Climate Change Centre of Excellence (192x96)
  - FGOALS-g2       # LASG, Institute of Atmospheric Physics, Chinese Academy of  Sciences; and CESS, Tsinghua University (128x60)
  - HadGEM2-AO      # National Institute of Meteorological Research, Korea Meteorological Administration (192x145)
  - inmcm4          # Institute for Numerical Mathematics (180x120)
  - IPSL-CM5A-LR    # Institut Pierre-Simon Laplace (96x96)
  - MIROC-ESM       # Japan Agency for Marine-Earth Science and Technology, Atmosphere and Ocean Research Institute, and  National Institute for Environmental Studies (128x64)
  - MPI-ESM-LR      # Max Planck Institute for Meteorology (MPI-M) (192x96)
  - NorESM1-M       # Norwegian Climate Centre (144x96)
RcpNames:
  - rcp85           # Representative Concentration Pathway (RCP) 8.5 Scenarios
VarNames:
  - pr              #Precipitation (mm)
  - tasmax          #Max. temperature (C)
  - tasmin          #Min. temperature (C)
NtlCode: KR
stnfile: Station-Info.csv   # Station meta file, name it dishtinguibly in case many regions involved.
bndfile: Korea.shp
OWrite: TRUE
SRadiation: FALSE

You are expected to have some exposure to those arguments, now see each of them one by one. At first, you create a super directory at large memory available path with name distinguishable, date and region are really good things to be written in the name, making your job path distinguishable. In this vignette, I name the name "APCC"(APEC Climate Center). D:/APCC.

prjdir: D:/APCC/project # This is your project directory where the downscaled results would be filed up.
dbdir: D:/APCC/Database # This is your database directory where the CMIP5 data needed for the work would be saved.
stndir: $(prjdir)/Observed/Korea # This is the directory to be filed up with observation data. I name it "Korea" in this tutorial

Above three directories(prjdir, dbdir, stndir) must be prepared(created) in advance. That's because we assume you have your own observation data beforehand. You need to store station csv file and observation csv file in stndir(station directory). Station file(stnfile) is described in detail below. Observation file should be csv formatted and look like this. Each file name must contain the station ID(eg, ID108).

|Year|Mon|Day|Pcp(mm)|Tmax(c)|Tmin(c)|WSpeed(m/s)|RHumidity(fr)|SRad(MJ/m2)| |:--:|:-:|:-:|:-----:|:-----:|:-----:|:---------:|:-----------:|:---------:| |1969| 1 | 1 | 0.1 | -3.3 | -11 | 1.5 | 0.727 | 13.9 | |1969| 1 | 2 | 0 | -6.4 | -12.9 | 1.8 | 0.8 | 12.8 | |1969| 1 | 3 | 0.1 | -4.2 | -14.4 | 2.6 | 0.813 | 7.75 | |1969| 1 | 4 | 0 | 0.7 | -10.4 | 2.7 | 0.617 | 16.46 | |1969| 1 | 5 | 3.9 | -1 | -8.6 | 4.4 | 0.86 | 8.44 | |1969| 1 | 6 | ... | ... | ... | ... | ... | ... |

Note : Day is month day not Julian format, that is, 2017/2/1 works but 2017/2/32 does not.
Header names are not much critical, but the order is. Year, Month, Day, Precipitation, Tasmax, Tasmin, Wind Speed, Relative Humidity, and Solar Radiation should be in this order. Of course, the unit matters too.

bnddir: $(prjdir)/gis-boundary # Under development, providing shp. files for further work.
qmapdir: $(prjdir)/Downscale/SQM # This directory will contain final result passed through SQM(Simple Quantile Mapping)
syear_obs: 1976     # Starting year of observed data
eyear_obs: 2005     # Ending year of observed data
syear_his: 1976     # Starting year of historical period (GCM)
eyear_his: 2005     # Ending year of historical period (GCM)
syear_scn:         
  - 2010
  - 2040
eyear_scn:
  - 2039
  - 2069            # Start years and End years of climate change scenario.
SimAll: FALSE       # Option for simulation all (GCM model, Variable, RCPs) combinations

If you put TRUE to SimAll argument, your process runs over all the models including GCMs, RCMs and RCPs. Obviously, takes a long time.

ModelNames:
  - bcc-csm1-1-m    # Beijing Climate Center,  China Meteorological Administration (128x64)
  - CanESM2         # Canadian Centre for Climate Modelling and Analysis (128x64)
  - CMCC-CMS        # Centro Euro-Mediterraneo per I Cambiamenti Climatici (192x96)
  - CSIRO-Mk3-6-0   # Commonwealth Scientific and Industrial Research Organisation in  collaboration with the Queensland Climate Change Centre of Excellence (192x96)
  - FGOALS-g2       # LASG, Institute of Atmospheric Physics, Chinese Academy of  Sciences; and CESS, Tsinghua University (128x60)
  - HadGEM2-AO      # National Institute of Meteorological Research, Korea Meteorological Administration (192x145)
  - inmcm4          # Institute for Numerical Mathematics (180x120)
  - IPSL-CM5A-LR    # Institut Pierre-Simon Laplace (96x96)
  - MIROC-ESM       # Japan Agency for Marine-Earth Science and Technology, Atmosphere and Ocean Research Institute, and  National Institute for Environmental Studies (128x64)
  - MPI-ESM-LR      # Max Planck Institute for Meteorology (MPI-M) (192x96)
  - NorESM1-M       # Norwegian Climate Centre (144x96)
RcpNames:
  - rcp85           # Representative Concentration Pathway (RCP) 8.5 Scenarios

Otherwise, FALSE on SimAll, and specify model names you want to use in simulation.

VarNames:
  - pr              #Precipitation (mm)
  - tasmax          #Max. temperature (C)
  - tasmin          #Min. temperature (C)

Variable names, pr(precipitation inmm), tasmax/tasmin(max/min temperature in Celcius degree), sfcWind(wind speed in m/s), rhs(relative humidity in fraction, not percentage), rsds(solar radiation in Mega Joule per square meter)

NtlCode: KR         

National Code used when downloading clipped CMIP5 data from ADSS(APEC Data Service Syetem). See below tables.

table1. Available national-level data based on clipped CMIP5 climate change scenario data.

| Region | Code | xmin | ymin | xmax | ymax | |:------:|:----:|:----:|:----:|:----:|:----:| | Bangladesh| BD| 88.03| 20.59| 92.67| 26.63| | Bhutan| BT| 88.76| 26.71| 92.13| 28.32| | Burma| MM| 92.19| 9.60| 101.18| 28.54| | Cambodia| KH| 102.34| 9.91| 107.63| 14.69| | Chile| CL| -109.46| -55.98| -66.42| -17.51| | Colombia| CO| -81.73| -4.23| -66.87| 13.39| | Cuba| CU| -84.96| 19.83| -74.13| 23.59| | Egypt| EG| 24.70| 21.73| 36.24| 31.67| | Ethiopia| ET| 33.00| 3.40| 47.99| 14.89| | Federated States of Micronesia| FM| 138.05| 5.26| 163.03| 11.68| | Fiji| FJ| -180| -20.68| 180| -12.48| | India| IN| 68.16| 6.75| 97.40| 35.50| | Indonesia| ID| 95.01| -11.00| 141.02| 5.90| | Iran| IR| 44.05| 25.06| 63.32| 39.78| | Kenya| KE| 33.91| -4.68| 41.90| 4.63| | Malaysia| MY| 98.94| 0.86| 119.27| 7.36| | Marshall Islands| MH| 165.26| 4.57| 172.16| 14.66| | Mongolia| MN| 87.75| 41.57| 119.92| 52.15| | Nepal| NP| 80.06| 26.36| 88.20| 30.43| | Philippines| PH| 116.93| 4.61| 126.60| 21.12| | Pakistan| PK| 60.88| 23.69| 77.84| 37.10| | Papua New Guinea| PG| 140.84| -11.66| 159.48| -0.88| | Samoa| WS| -172.80| -14.06| -171.41| -13.43| | South Korea| KR| 124.61| 33.11| 130.92| 38.61| | Tanzania| TZ| 29.33| -11.75| 40.44| -0.99| | Thailand| TH| 97.35| 5.61| 105.64| 20.46| | Timor-Leste| TL| 124.04| -9.50| 127.34| -8.13| | Tonga| TO| -176.21| -22.35| -173.70| -15.56| | Vietnam| VN| 102.15| 8.41| 109.46| 23.39| | Zambia| ZM| 22.00| -18.08| 33.71| -8.22|

table2. Available United State data based on clipped CMIP5 climate change scenario data.

| Region | Code | xmin | ymin | xmax | ymax | |:------:|:----:|:----:|:----:|:----:|:----:| | Alabama | USAL| -88.47| 30.22| -84.89| 35.01| | Alaska| USAK| -168.12| 54.76| -129.99| 72.69| | Arizona| USAZ| -114.82| 31.33| -109.04| 37.00| | Arkansas| USAR| -94.62| 33.00| -89.64| 36.50| | California| USCA| -124.42| 32.53| -114.13| 42.01| | Colorado| USCO| -109.06| 36.99| -102.04| 41.01| | Connecticut| USCT| -73.73| 40.98| -71.79| 42.05| | Delaware| USDE| -75.79| 38.43| -75.05| 39.84| | District of Columbia| USDC| -77.12| 38.81| -76.91| 39.00| | Florida| USFL| -87.64| 24

Related Skills

View on GitHub
GitHub Stars5
CategoryDevelopment
Updated3y ago
Forks0

Languages

R

Security Score

55/100

Audited on Mar 29, 2023

No findings