Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add spatial disaggregation recipe #57

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

dgergel
Copy link
Contributor

@dgergel dgergel commented Jan 13, 2021

This PR adds the following:

  1. a full recipe for implementing the Thrasher et al. 2012 method for spatial disaggregation that is part of the Bias Correction and Spatial Disaggregation (BCSD) daily downscaling method
  2. structure for a new class of spatial models
  3. a fit/predict method for spatial disaggregation using the SpatialDisaggregator class in spatial models

@jhamman
Copy link
Member

jhamman commented Jan 15, 2021

@dgergel - I just merged some changes in that should fix the CI for you. Go ahead and pull those in and then I'll take a look here.

@dgergel
Copy link
Contributor Author

dgergel commented Jan 29, 2021

@jhamman sorry for the delay in fixing the pre-commit problems. This is finally ready for a review.

Copy link
Member

@jhamman jhamman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks cool. Just a few comments to tidy things a bit but let's merge this soon. I suspect some iteration around the spatial models api will be needed but its good to start somewhere.

Oh! And tests, can you pull a basic set of unit tests together for the SpatialDisaggregator?

Comment on lines 23 to 27
if var == 'temperature':
pass
elif var == 'precipitation':
pass
else:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's write this as:

Suggested change
if var == 'temperature':
pass
elif var == 'precipitation':
pass
else:
if var not in ['temperature', 'precipitation'] :

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Comment on lines 55 to 58
if not np.array_equal(ds_bc[lat_name], climo_coarse[lat_name]):
raise ValueError('climo latitude dimension does not match model res')
if not np.array_equal(ds_bc[lon_name], climo_coarse[lon_name]):
raise ValueError('climo longitude dimension does not match model res')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe something like this:

Suggested change
if not np.array_equal(ds_bc[lat_name], climo_coarse[lat_name]):
raise ValueError('climo latitude dimension does not match model res')
if not np.array_equal(ds_bc[lon_name], climo_coarse[lon_name]):
raise ValueError('climo longitude dimension does not match model res')
if not ds_bc[lat_name].equals(climo_coarse[lat_name]):
raise ValueError('climo latitude coordinate does not match model res')
if not ds_bc[lon_name].equals(climo_coarse[lon_name]):
raise ValueError('climo longitude coordinate does not match model res')

Comment on lines +16 to +17
specifies the variable being downscaled. Default is
temperature and other option is precipitation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit but these are over-indented (same for all docstrings here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fixed now.

Base automatically changed from master to main February 23, 2021 18:56
@codecov
Copy link

codecov bot commented Apr 20, 2021

Codecov Report

Merging #57 (098d8ea) into main (8a0c27e) will not change coverage.
The diff coverage is n/a.

❗ Current head 098d8ea differs from pull request most recent head 458f292. Consider uploading reports for the commit 458f292 to get more accurate results
Impacted file tree graph

@@    Coverage Diff     @@
##   main   #57   +/-   ##
==========================
==========================

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8a0c27e...458f292. Read the comment docs.

@dgergel
Copy link
Contributor Author

dgergel commented Apr 20, 2021

@jhamman so sorry for taking so long to get back to this. I've made the changes you suggested and added unit tests, so this is ready for another review.

@jhamman jhamman mentioned this pull request Dec 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants