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

Adding detrending/drift removal functionality #123

Closed
jbusecke opened this issue May 21, 2021 · 4 comments · Fixed by #126
Closed

Adding detrending/drift removal functionality #123

jbusecke opened this issue May 21, 2021 · 4 comments · Fixed by #126

Comments

@jbusecke
Copy link
Owner

I have developed quite a bit of logic to remove control run drift from CMIP6 models for my recent OMZ paper, and would like to refactor this into cmip6_preprocessing.

The logic I use has these basic steps:

  • Use the metadata of every historical member (see Better structure for different 'levels' of preprocessing. #95 for further explanation of nomenclature) to get the branch time in the parent piControl run branch_time_parent.
  • Select a 250 year time period starting at branch_time_parent, and calculate a linear slope at every x, y, and lev position. Save that output
  • Remove this trend from historical and forced runs by assuming an intercept of 0 at time 1850-01-01 (the time when the historical forcing starts).

I will migrate this functionality here (and would then welcome feedback), but I wanted to discuss the API first.

First of all I was wondering about how to call the module (which I would create for this purpose):

  • cmip6_preprocessing/drift_correction
  • cmip6_preprocessing/time_tools (this could more general time related functionality like dealing with the time dimension #64, which is also needed for the above tools)
  • cmip6_preprocessing/detrending (seems a bit ambiguous to me?)
    Not super stoked about these yet. Any ideas?

For the API I would imagine something along the lines of:

from cmip6_preprocessing.cool_modulename import sel_from_branch, detrend

ds = ...
ds_control ... # matching control run (can be inferred and matched from attributes similar as in #120)

matching_control = sel_from_branch(ds, ds_control, yrs=250)
slope = matching_control.polyfit(dim='time', deg=1)
# in a realistic workflow I would save these files out (they are relatively small) and load them back for analysis
ds_nodrift = detrend(ds, slope, start_date = '1850-01-01`)

Any thoughts?

cc @MackenzieBlanusa

@jbusecke jbusecke changed the title Adding detrending functionality Adding detrending/drift removal functionality May 21, 2021
@MackenzieBlanusa
Copy link

For a module name, I think cmip6_preprocessing/drift_correction is a good choice. The API is nice and straightforward. I'm a little confused on matching the control run. Do you match the control run with historical members?

@jbusecke
Copy link
Owner Author

Thanks for the feedback @MackenzieBlanusa. Yes my approach is to find the time where the 'historical' run was split from 'piControl', the 250 year linear trend should then be applicable to any combination of 'historical' and scenarios.
This makes sure that we only suptract a single linear trend.

I am not sure if one can make an argument to detrend the scenarios separately, but in that case I would be worried that the different duration could lead to spurious signals due to interannual-decdal variability in the control.

What do you think?

@MackenzieBlanusa
Copy link

Thanks for the clarification @jbusecke. I agree with your concern about detrending the scenarios separately. I think it would be best to just work with the single linear trend obtained from the historical and piControl.

@jbusecke
Copy link
Owner Author

jbusecke commented Jun 1, 2021

Ill try to start working on this today, and will ping you here once I have a working PR.

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 a pull request may close this issue.

2 participants