-
Notifications
You must be signed in to change notification settings - Fork 4
make_grid_info - Part 1 #79
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
base: main
Are you sure you want to change the base?
Conversation
… be able to use logging, move the latlon specific stuff from make_grid_info into its own function, documents the members of the hgridobj
| self.jsc = None | ||
| self.jec = None | ||
|
|
||
| def __init_numpy_arrays__(self, nsuper, narea, ndx, ndy): |
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.
do the arrays need to be initialized beforehand in python?
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.
ok init is a bad name, __allocate_numpy_arrays__?
This is allocating memory for all of the 1D members of HGridObj
They are set in pyfrenctools.make_hgrid_wrappers.create_*, which is why they are allocated here.
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.
I think the allocation can be abstracted into pyfrenctools.make_hgrid_wrappers.create_* (do the allocation there and return the appropriate arrays)
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.
The way I see this turning out is
-
For lat/lon grids in lonlat_grid.py
-> grid_obj = HGridObj() (initiliazed the hgrid object)
-> grid_obj.make_grid_info_lat_lon(...) (set up the arrays to hold the data)
-> pyfrenctools.make_hgrid_wrappers.create_regular_lonlat_grid( ...) (fill in the arrays)
-> grid_obj.write_out_hgrid(...) (write out the data) -
Simlarly for cubesphere grids in gnomonic_grid.py
-> grid_obj = HGridObj() (initiliazed the hgrid object)
-> grid_obj.make_grid_info_gnomonic(...) (set up the arrays to hold the data)
-> pyfrenctools.make_hgrid_wrappers.create_regular_lonlat_grid( ...) (fill in the arrays)
-> grid_obj.write_out_hgrid(...) (write out the data)
make_grid_info_lat_lon and make_grid_info_gnomonic are going to share code like __allocate_numpy_arrays__
make_grid_info_gnomonic has to do extra stuff (i.e grid_obj.x has a size of nlon * nlon * 6 for non nesting grids and nlon * nlon * 6 + nest_x * nest_y) for grids with nests
Let's talk about this tomorrow :)
|
|
||
| self.logger.debug(f"make_grid_info: Creating a lat-lon with nlon={nlon} and nlat={nlat}") | ||
|
|
||
| self.nxl = np.array(nlon, dtype=np.int32) |
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.
is nxl, nyl just scalars? They probably can just be self.nxl = nlon...
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.
They are 1D integers of size equal to the number of tiles. In this lat/lon case they are just one. The code that writes the output is currently expecting them to be arrays.
FMSgridtools/fmsgridtools/make_hgrid/hgridobj.py
Lines 456 to 457 in b2cfa66
| nx = self.nxl[n] | |
| ny = self.nyl[n] |
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.
ooo.... that should be changed...
(yup, unnecessarily complicated)
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.
Yes, there is a lot of unnecessarily complicated code.
I am just tackling this one step at a time.
| ntiles = 6 | ||
| ratio = 2 | ||
| grid_size = 96 | ||
| nlon = np.array([grid_size], dtype=np.int32) |
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.
no need for scalars to be "np.array"'s
This PR: