Skip to content

Commit

Permalink
fix angle rotation bug (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
yichengt900 authored Apr 3, 2024
1 parent 39b3a7f commit 004a335
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions tools/boundary/boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,17 @@ class Segment():
ny (int): Number of data points in the y direction.
"""

def __init__(self, num, border, hgrid, in_degrees=True, output_dir='.', regrid_dir=None):
def __init__(self, num, border, hgrid, in_degrees=False, output_dir='.', regrid_dir=None):
self.num = num
self.border = border
self.hgrid = hgrid
if in_degrees:
# Need to make a copy of hgrid so that the original is not modified multiple times
# when creating multiple segments
self.hgrid = hgrid.copy(deep=True)
# Check if the angle_dx variable in ocean_hgrid has a 'units' attribute
angle_units = hgrid['angle_dx'].attrs.get('units', None)
# If the units attribute is degrees, or degrees were manually specified, convert to radians
if angle_units == 'degrees' or in_degrees:
print('Converting grid angle from degrees to radians')
self.hgrid['angle_dx'] = np.radians(self.hgrid['angle_dx'])
check_angle_range(self.hgrid['angle_dx'])
self.segstr = f'segment_{self.num:03d}'
Expand Down
2 changes: 1 addition & 1 deletion tools/boundary/write_glorys_boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def main(config_file):

# Parse command-line arguments
parser = argparse.ArgumentParser(description='Generate obc from Glorys')
parser.add_argument('--config', type=str, default=glorys_obc.yaml,
parser.add_argument('--config', type=str, default='glorys_obc.yaml',
help='Specify the YAML configuration file name')
args = parser.parse_args()

Expand Down

0 comments on commit 004a335

Please sign in to comment.