-
Notifications
You must be signed in to change notification settings - Fork 7
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
first attempt at adding basic bias correction code and fixing tests #2
Changes from 15 commits
2416a81
4a0a48e
4ac1718
7f74f91
65ae323
ba02a5e
bc82192
3d79cb0
6705bae
c71f4b5
3d1a23a
8fe8ab5
e948a95
d9bf192
9f2c58e
404cb6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,17 +3,47 @@ | |
Math stuff and business logic goes here. This is the "business logic". | ||
""" | ||
|
||
# import numpy as np | ||
# import xarray as xr | ||
# from skdownscale.pointwise_models import PointWiseDownscaler, BcsdTemperature | ||
import numpy as np | ||
import xarray as xr | ||
from skdownscale.pointwise_models import PointWiseDownscaler, BcsdTemperature | ||
|
||
# Break this down into a submodule(s) if needed. | ||
# Assume data input here is generally clean and valid. | ||
|
||
|
||
def climatenerdlogic(*args): | ||
raise NotImplementedError | ||
def bias_correct_bcsd( | ||
gcm_training_ds, obs_training_ds, gcm_predict_ds, train_variable, out_variable | ||
): | ||
|
||
"""Bias correct input model data using BCSD method, | ||
using either monthly or +/- 15 day time grouping. | ||
|
||
Parameters | ||
---------- | ||
gcm_training_ds : Dataset | ||
training model data for building quantile map | ||
obs_training_ds : Dataset | ||
observation data for building quantile map | ||
gcm_predict_ds : Dataset | ||
future model data to be bias corrected | ||
predicted : Dataset | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this "predicted" arg was renamed or removed. If so I'd remove the two docstr lines for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch - it should be |
||
bias corrected future model data | ||
train_variable : str | ||
variable name used in training data | ||
out_variable : str | ||
variable name used in downscaled output | ||
""" | ||
|
||
# note that time_grouper='daily_nasa-nex' is what runs the | ||
# NASA-NEX version of daily BCSD | ||
# TO-DO: switch to NASA-NEX version once tests pass | ||
model = PointWiseDownscaler(BcsdTemperature(return_anoms=False)) | ||
model.fit(gcm_training_ds[train_variable], obs_training_ds[train_variable]) | ||
predicted = model.predict(gcm_predict_ds[train_variable]).load() | ||
ds_predicted = predicted.to_dataset(name=out_variable) | ||
return ds_predicted | ||
|
||
|
||
def morenerdymathstuff(*args): | ||
raise NotImplementedError | ||
# TO-DO: implement additional bias correction functionality | ||
return None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you're set to just remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed - done 👍 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
click | ||
cftime | ||
numpy | ||
scikit-downscale | ||
git+https://github.com/dgergel/xsd@pointwisedownscaler_interimfix | ||
xarray |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think can remove
numpy
andxarray
imports - they're not used.