Giter Club home page Giter Club logo

bcsd-python's Introduction

Bias Correction Spatial Disaggregation

This code was used in this 2019 paper: Intercomparison of machine learning methods for statistical downscaling: the case of daily and extreme precipitation

Prism Downscaling MERRA-2 - Precipitation

Requirements

Data

Merra 2 - A reanalysis dataset provided by NASA's Global Modeling and Assimilation Office. We extract preciptation from the land product to downscale. Reanalysis datasets are used to test a downscaling model's skill against an observed dataset. https://gmao.gsfc.nasa.gov/reanalysis/MERRA-2/

Prism - The prism 4km precipitation dataset is aggregated to 16km, which will be our observations. http://www.prism.oregonstate.edu/

Preprocessing of data

  • Interplate missing values
  • Upscale Prism and remap to MERRA
  • Merge all years into single files, 1 per data source
cd data
prism='prism_example.nc'
merra='merra_example.nc'
prism_upscaled='prism_upscaled.nc'
merra_filled='merra_filled.nc'

cdo griddes $merra > merra_grid
# This trick of setting and resetting the missing value seems to allow fillmiss to work
#     if resetting is not done then merra_prism_example.py won't read the file correctly
cdo setmissval,nan $prism temp_miss.nc
cdo fillmiss temp_miss.nc tmp.nc
cdo setmissval,-9999 tmp.nc tmp_filled.nc
cdo remapbil,merra_grid -gridboxmean,3,3 tmp_filled.nc $prism_upscaled
cdo fillmiss $merra $merra_filled
rm tmp_filled.nc

Bias Correction

python ../merra_prism_example.py $prism_upscaled $merra_filled ppt PRECTOTLAND merra_bc.nc

Spatial Disaggregation - Scaling

Remap Bias Corrected Merra to the High Resolution Prism

cdo griddes $prism > prism_grid
cdo remapbil,prism_grid merra_bc.nc merra_bc_interp.nc 

Interpolate upscaled Prism to Original Resolution

cdo remapbil,prism_grid $prism_upscaled prism_reinterpolated.nc

Compute scaling Factors

cdo ydayavg prism_reinterpolated.nc prism_interpolated_ydayavg.nc
cdo ydayavg $prism prism_ydayavg.nc
cdo div prism_ydayavg.nc prism_interpolated_ydayavg.nc scale_factors.nc

Execute Spatial Scaling

python ../spatial_scaling.py merra_bc_interp.nc scale_factors.nc merra_bcsd.nc

Masking (optional)

The dataset provided does not contain any bodies of water but when downscaling north america the ocean is filled with interpolated values. After spatial scaling we'll want to replace filled values with NaN. Here, we build a dataset with 1's over land and NaN over bodies of water.

cdo seltimestep,1 -div -addc,1 $prism -addc,1 $prism mask.nc
cdo mul mask.nc merra_bcsd.nc merra_bcsd_masked.nc

bcsd-python's People

Contributors

tjvandal avatar

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.