-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add variable baseline functionality to anomaly plot function #11
Comments
Hi Jake, This is a fantastic idea, and your implementation is brilliant. Thanks for describing the changes so meticulously. Is there a reason you got rid of the threshold option? That's a bit of functionality I'd like to keep, because it's a somewhat common way of displaying ENSO anomalies |
Oops, that was not intentional. I was using the anomaly code published on File Exchange, which does not seem to have the threshold option. I'll rewrite it using the CDT anomaly function, which seems to be the most recent one. |
The following edits were applied to the anomaly.m file in this repository: Line 70
Data manipulation
This section is now redundant:
Check for and remove NaNs both in y and thresh:
The
Adding zero crossings to the both thresh vectors, and sorting them with xb/xt
Separating y into a top and a bottom dataset changes as follows:
Plotting
This should be it :) Code: anomaly_varthresh.m.zip |
The anomaly plot function could be much more versatile by allowing the user to specify a variable baseline. This is useful for visualising differences between the annual trend of a given parameter and its climatological mean. This is an example plot:
Implementing this into the code is pretty straightforward:
Assert that the base is either a scalar (constant baseline) or a vector the same length as x and y (variable baseline):
If base is a scalar, convert it into a column vector the length of y (before "Columnate inputs to ensure...":
Columnate base just like x and y (only relevant if base is not a scalar):
Find NaNs both in y and base so filling will work (and remove them from base as well):
The
intersections
subfunction now simplifies as follows:Add zero crossings to base:
Splitting the data into a top and bottom dataset changes as follows:
Instead of using
area
we now need to usefill
, the output remains the same:VOILA! This will allow the user to provide either a constant or a variable baseline and the code will do the rest:
Here is a copy of the adjusted code:
anomaly_JW.m.zip
I hope this is helpful.
Cheers,
Jake
The text was updated successfully, but these errors were encountered: