Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions ush/python_utils/fv3write_parms_lambert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/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

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
62 changes: 58 additions & 4 deletions ush/set_predef_grid_params.sh
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ case ${PREDEF_GRID_NAME} in
ESGgrid_NY="232"

ESGgrid_PAZI="0.0"

ESGgrid_WIDE_HALO_WIDTH="6"

DT_ATMOS="${DT_ATMOS:-45}"
Expand Down Expand Up @@ -389,7 +389,7 @@ case ${PREDEF_GRID_NAME} in
ESGgrid_NY="600"

ESGgrid_PAZI="0.0"

ESGgrid_WIDE_HALO_WIDTH="6"

DT_ATMOS="${DT_ATMOS:-40}"
Expand Down Expand Up @@ -486,7 +486,7 @@ case ${PREDEF_GRID_NAME} in
ESGgrid_NY="240"

ESGgrid_PAZI="0.0"

ESGgrid_WIDE_HALO_WIDTH="6"

# DT_ATMOS="${DT_ATMOS:-50}"
Expand Down Expand Up @@ -606,7 +606,7 @@ case ${PREDEF_GRID_NAME} in
ESGgrid_NY="1020"

ESGgrid_PAZI="0.0"

ESGgrid_WIDE_HALO_WIDTH="6"

# DT_ATMOS="${DT_ATMOS:-50}"
Expand Down Expand Up @@ -635,6 +635,60 @@ case ${PREDEF_GRID_NAME} in
#
#-----------------------------------------------------------------------
#
# The WoFS domain with ~3km cells.
#
# Note:
# The WoFS domain will generate a 301 x 301 output grid (WRITE COMPONENT) and
# will eventually be movable (ESGgrid_LON_CTR/ESGgrid_LAT_CTR). A python script
# python_utils/fv3write_parms_lambert will be useful to determine
# WRTCMP_lon_lwr_left and WRTCMP_lat_lwr_left locations (only for Lambert map
# projection currently) of the quilting output when the domain location is
# moved. Later, it should be integrated into the workflow.
#
#-----------------------------------------------------------------------
#
"WoFS_3km")

GRID_GEN_METHOD="ESGgrid"

ESGgrid_LON_CTR="-97.5"
ESGgrid_LAT_CTR="38.5"

ESGgrid_DELX="3000.0"
ESGgrid_DELY="3000.0"

ESGgrid_NX="361"
ESGgrid_NY="361"

ESGgrid_PAZI="0.0"

ESGgrid_WIDE_HALO_WIDTH="6"

DT_ATMOS="${DT_ATMOS:-20}"

LAYOUT_X="${LAYOUT_X:-18}"
LAYOUT_Y="${LAYOUT_Y:-12}"
BLOCKSIZE="${BLOCKSIZE:-30}"

if [ "$QUILTING" = "TRUE" ]; then
WRTCMP_write_groups="1"
WRTCMP_write_tasks_per_group=$(( 1*LAYOUT_Y ))
WRTCMP_output_grid="lambert_conformal"
WRTCMP_cen_lon="${ESGgrid_LON_CTR}"
WRTCMP_cen_lat="${ESGgrid_LAT_CTR}"
WRTCMP_stdlat1="${ESGgrid_LAT_CTR}"
WRTCMP_stdlat2="${ESGgrid_LAT_CTR}"
WRTCMP_nx="301"
WRTCMP_ny="301"
WRTCMP_lon_lwr_left="-102.3802487"
WRTCMP_lat_lwr_left="34.3407918"
WRTCMP_dx="${ESGgrid_DELX}"
WRTCMP_dy="${ESGgrid_DELY}"
fi
;;
#
#-----------------------------------------------------------------------
#
# A CONUS domain of GFDLgrid type with ~25km cells.
#
# Note:
Expand Down
3 changes: 2 additions & 1 deletion ush/valid_param_vals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ valid_vals_PREDEF_GRID_NAME=( \
"RRFS_NA_13km" \
"RRFS_NA_3km" \
"SUBCONUS_Ind_3km" \
"WoFS_3km" \
)
valid_vals_CCPP_PHYS_SUITE=( \
"FV3_GFS_2017_gfdlmp" \
Expand All @@ -41,7 +42,7 @@ valid_vals_CCPP_PHYS_SUITE=( \
"FV3_RRFS_v1beta" \
"FV3_RRFS_v1alpha" \
"FV3_HRRR" \
)
)
valid_vals_GFDLgrid_RES=("48" "96" "192" "384" "768" "1152" "3072")
valid_vals_EXTRN_MDL_NAME_ICS=("GSMGFS" "FV3GFS" "RAP" "HRRR" "NAM")
valid_vals_EXTRN_MDL_NAME_LBCS=("GSMGFS" "FV3GFS" "RAP" "HRRR" "NAM")
Expand Down