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

forcing conversion format for SAM LES #155

Open
xychen-ocn opened this issue Mar 11, 2022 · 4 comments
Open

forcing conversion format for SAM LES #155

xychen-ocn opened this issue Mar 11, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@xychen-ocn
Copy link

The toolbox is super convenient and easy to use ! I was just wondering if there is a forcing conversation format for SAM currently. I asked Peter Blossey about this and he shared a Matlab conversion function with me which he used to convert the racmo-formatted forcings from Lagtraj a year ago. If the conversion format for SAM is not available yet, I wonder how I can get the racmo-formatted forcings from Lagtraj.

@leifdenby
Copy link
Contributor

leifdenby commented Mar 11, 2022

The toolbox is super convenient and easy to use ! I was just wondering if there is a forcing conversation format for SAM currently. I asked Peter Blossey about this and he shared a Matlab conversion function with me which he used to convert the racmo-formatted forcings from Lagtraj a year ago. If the conversion format for SAM is not available yet, I wonder how I can get the racmo-formatted forcings from Lagtraj.

Hey @xychen-ocn! Thanks for the kind words (and for getting in touch on Mattermost!)

The steps to get this to work is create a file in lagtraj/forcings/conversion/targets called say sam.py with a function inside it called from_era5 (you can check out the one for KPT format here: https://github.com/EUREC4A-UK/lagtraj/blob/master/lagtraj/forcings/conversion/targets/kpt.py#L315). The function should accept four things ds_era5, da_levels, parameters and metadata, and return the converted forcings as a xr.Dataset. We need to add some documentation for the inputs, but basically these are the forcing profile(s), height levels, parameters (e.g. flags that can be turned on/off in the conversion yaml file, or constants you might want to set/use in the conversion) and meta-info to add to the output file. If you have a look at the other conversion examples you can get an idea what is going on. The other thing to add is a yaml-file describing a "sensible defaults" for producing a conversion for SAM, called sam.yaml. You can see some examples for the other models lagtraj currently can target here: https://github.com/EUREC4A-UK/lagtraj/tree/master/lagtraj/input_definitions/examples_files/forcings_conversion. And that's it, after that it "should just work" 😆

Depending on how you feel about it you could have a go a creating this yourself? :) I'd be very happy to review/give suggestions if you make a pull-request and then we could add this to lagtraj. Also, if you want to add the matlab file here to the discussion I could also help make suggestions for how to implement each step in python.

@leifdenby leifdenby added the enhancement New feature or request label Mar 11, 2022
@xychen-ocn
Copy link
Author

Thanks for the step-by-step explanation! Let me give it a try~
Here is the matlab files Peter Blossey shared. https://atmos.uw.edu/~bloss/nobackup/forXuanYu/LagtrajToSCAMNetcdfConversion.tgz
The main script is "ConvertLeedsEUREC4AForcings.m".

@xychen-ocn
Copy link
Author

Hi @leifdenby, I am almost there converting Peter's matlab script to sam.py. I wonder if I can test the sam conversion locally on my end before making a pull request. Thanks!

@leifdenby
Copy link
Contributor

Hi @leifdenby, I am almost there converting Peter's matlab script to sam.py. I wonder if I can test the sam conversion locally on my end before making a pull request. Thanks!

That's awesome! Yes, feel free to add a pull-request already (you can always mark it as a "draft" if you want). I can give you some tips on how to improve it/solve problems etc if you need me to :)

I don't know if you spotted it but I recently updated the development notes I wrote for lagtraj: https://github.com/EUREC4A-UK/lagtraj/blob/master/docs/developing.md - the main change is that I set up the use of pre-commit for linting (instead of having to run linting commands manually). It's really easy and just happens automatically with every commit. Let me know if you have an issues with it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants