-
Notifications
You must be signed in to change notification settings - Fork 87
Added a fixed WoF grid and the python tool to determine the write component parameters #733
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
Merged
ywangwof
merged 5 commits into
ufs-community:develop
from
ywangwof:feature/WoFS_3km_grid
Apr 29, 2022
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
06a188c
Added a fixed WoF grid and the python tool to determine the write com…
ywangwof eb33dcf
Update set_predef_grid_params.sh
JeffBeck-NOAA 78f6637
Merged with develop
990e803
Renamed file as recommended and removed unused lines
ebf00b1
Modified comment
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| #!/usr/bin/env python | ||
| # | ||
| # To use this tool, you should source the regional workflow environment | ||
| # $> source env/wflow_xxx.env | ||
| # and activate pygraf (or any one with cartopy installation) | ||
| # $> conda activate pygraf | ||
| # | ||
|
|
||
| import argparse | ||
|
|
||
| import cartopy.crs as ccrs | ||
|
|
||
| #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ||
| # | ||
| # Main function to return parameters for the FV3 write component. | ||
| # | ||
|
|
||
| if __name__ == "__main__": | ||
|
|
||
| parser = argparse.ArgumentParser(description='Determine FV3 write component lat1/lon1 for Lamert Conformal map projection', | ||
| epilog=''' ---- Yunheng Wang (2021-07-15). | ||
| ''') | ||
| #formatter_class=CustomFormatter) | ||
| parser.add_argument('-v','--verbose', help='Verbose output', action="store_true") | ||
| parser.add_argument('-ca','--ctrlat', help='Lambert Conformal central latitude', type=float, default=38.5 ) | ||
| parser.add_argument('-co','--ctrlon', help='Lambert Conformal central longitude', type=float, default=-97.5 ) | ||
| parser.add_argument('-s1','--stdlat1',help='Lambert Conformal standard latitude1', type=float, default=38.5 ) | ||
| parser.add_argument('-s2','--stdlat2',help='Lambert Conformal standard latitude2', type=float, default=38.5 ) | ||
| parser.add_argument('-nx', help='number of grid in X direction', type=int, default=301 ) | ||
| parser.add_argument('-ny' ,help='number of grid in Y direction', type=int, default=301 ) | ||
| parser.add_argument('-dx' ,help='grid resolution in X direction (meter)',type=float, default=3000.0) | ||
| parser.add_argument('-dy' ,help='grid resolution in Y direction (meter)',type=float, default=3000.0) | ||
|
|
||
| args = parser.parse_args() | ||
|
|
||
| if args.verbose: | ||
| print("Write component Lambert Conformal Parameters:") | ||
| print(f" cen_lat = {args.ctrlat}, cen_lon = {args.ctrlon}, stdlat1 = {args.stdlat1}, stdlat2 = {args.stdlat2}") | ||
| print(f" nx = {args.nx}, ny = {args.ny}, dx = {args.dx}, dy = {args.dy}") | ||
|
|
||
| #----------------------------------------------------------------------- | ||
| # | ||
| # Lambert grid | ||
| # | ||
| #----------------------------------------------------------------------- | ||
|
|
||
| nx1 = args.nx | ||
| ny1 = args.ny | ||
| dx1 = args.dx | ||
| dy1 = args.dy | ||
|
|
||
| ctrlat = args.ctrlat | ||
| ctrlon = args.ctrlon | ||
|
|
||
| #xsize1=(nx1-1)*dx1 | ||
| #ysize1=(ny1-1)*dy1 | ||
|
|
||
| #x1 = np.linspace(0.0,xsize1,num=nx1) | ||
| #y1 = np.linspace(0.0,ysize1,num=ny1) | ||
| # | ||
| #print(x1[0:3]) | ||
| #print(y1[0:3]) | ||
| #x1_2, y1_2 = np.meshgrid(x1,y1) | ||
|
ywangwof marked this conversation as resolved.
Outdated
|
||
|
|
||
| xctr = (nx1-1)/2*dx1 | ||
| yctr = (ny1-1)/2*dy1 | ||
|
|
||
| carr= ccrs.PlateCarree() | ||
|
|
||
| proj1=ccrs.LambertConformal(central_longitude=ctrlon, central_latitude=ctrlat, | ||
| false_easting=xctr, false_northing= yctr, secant_latitudes=None, | ||
| standard_parallels=(args.stdlat1, args.stdlat2), globe=None) | ||
|
|
||
| lonlat1 = carr.transform_point(0.0,0.0,proj1) | ||
|
|
||
| if args.verbose: | ||
| print() | ||
| print(f' lat1 = {lonlat1[1]}, lon1 = {lonlat1[0]}') | ||
| print('\n') | ||
|
|
||
| #----------------------------------------------------------------------- | ||
| # | ||
| # Output write component parameters | ||
| # | ||
| #----------------------------------------------------------------------- | ||
|
|
||
| print() | ||
| print("output_grid: 'lambert_conformal'") | ||
| print(f"cen_lat: {args.ctrlat}") | ||
| print(f"cen_lon: {args.ctrlon}") | ||
| print(f"stdlat1: {args.stdlat1}") | ||
| print(f"stdlat2: {args.stdlat2}") | ||
| print(f"nx: {args.nx}") | ||
| print(f"ny: {args.ny}") | ||
| print(f"dx: {args.dx}") | ||
| print(f"dy: {args.dy}") | ||
| print(f"lat1: {lonlat1[1]}") | ||
| print(f"lon1: {lonlat1[0]}") | ||
| print() | ||
|
|
||
| # End of program | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This package will likely not be supported by any of the existing conda environments on the supported platforms and should probably have an environment.yml change to reflect that.
Uh oh!
There was an error while loading. Please reload this page.
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.
It works with the environment for pygraf (see the comments in the script). I do not think it is necessary to add another environment.
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.
@christinaholtNOAA could you review again whether my new commits and comments satisfy your change request? Thanks.