Skip to content

Commit

Permalink
pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cbegeman committed Apr 14, 2023
1 parent d0b9095 commit f904806
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
31 changes: 16 additions & 15 deletions compass/ocean/tests/isomip_plus/forward.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import shutil
import time
import numpy as np

import numpy as np
import xarray

from compass.model import run_model
Expand Down Expand Up @@ -177,11 +177,12 @@ def run(self):
units='PSU', vmin=33.8, vmax=34.7, cmap='cmo.haline')
tol = 1e-10
dsIce = xarray.open_dataset(
os.path.join(self.work_dir, 'land_ice_fluxes.nc'))
os.path.join(self.work_dir,
'land_ice_fluxes.nc'))
plotter.plot_horiz_series(
dsIce.topDragMagnitude,
'topDragMagnitude', 'topDragMagnitude', True,
vmin=0+tol, vmax=np.max(dsIce.topDragMagnitude.values),
vmin=0 + tol, vmax=np.max(dsIce.topDragMagnitude.values),
cmap_set_under='k')
plotter.plot_horiz_series(
dsIce.landIceHeatFlux,
Expand All @@ -197,26 +198,26 @@ def run(self):
plotter.plot_horiz_series(
dsIce.landIceFreshwaterFlux,
'landIceFreshwaterFlux', 'landIceFreshwaterFlux', True,
vmin=0+tol,
vmax=1e-4, cmap_set_under='k', cmap_scale='log')
vmin=0 + tol, vmax=1e-4,
cmap_set_under='k', cmap_scale='log')
plotter.plot_horiz_series(
dsIce.landIceFraction,
'landIceFraction', 'landIceFraction', True,
vmin=0+tol, vmax=1-tol,
vmin=0 + tol, vmax=1 - tol,
cmap='cmo.balance',
cmap_set_under='k', cmap_set_over='r')
if 'landIceFloatingFraction' in dsIce.keys():
plotter.plot_horiz_series(dsIce.landIceFloatingFraction,
'landIceFloatingFraction',
'landIceFloatingFraction',
True, vmin=0+tol, vmax=1-tol,
cmap='cmo.balance',
cmap_set_under='k', cmap_set_over='r')
plotter.plot_horiz_series(
dsIce.landIceFloatingFraction,
'landIceFloatingFraction', 'landIceFloatingFraction',
True, vmin=0 + tol, vmax=1 - tol,
cmap='cmo.balance', cmap_set_under='k', cmap_set_over='r')

if self.name == 'simulation':
update_evaporation_flux(in_forcing_file='forcing_data_init.nc',
out_forcing_file='forcing_data_updated.nc',
out_forcing_link='forcing_data.nc')
update_evaporation_flux(
in_forcing_file='forcing_data_init.nc',
out_forcing_file='forcing_data_updated.nc',
out_forcing_link='forcing_data.nc')

replacements = {'config_do_restart': '.true.',
'config_start_time': "'file'"}
Expand Down
22 changes: 12 additions & 10 deletions compass/ocean/tests/isomip_plus/initial_state.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import shutil
import cmocean

import cmocean # noqa: F401
import numpy as np
import xarray as xr
from mpas_tools.cime.constants import constants
Expand Down Expand Up @@ -116,7 +116,8 @@ def _compute_initial_condition(self):
# when min_land_ice_fraction = 0
mask = ds.landIceFraction > min_land_ice_fraction

floating_mask = np.logical_and(ds.landIceFloatingFraction > 0,
floating_mask = np.logical_and(
ds.landIceFloatingFraction > 0,
ds.landIceFraction >= min_land_ice_fraction)

ds['landIceMask'] = mask.astype(int)
Expand Down Expand Up @@ -184,7 +185,8 @@ def _compute_initial_condition(self):
ds['salinity'] = \
(1.0 - frac) * init_top_sal + frac * init_bot_sal
# for thin film cells, set temperature to freezing point
ds['temperature'] = xr.where(thin_film_mask, thin_film_temp, ds.temperature)
ds['temperature'] = xr.where(thin_film_mask, thin_film_temp,
ds.temperature)

# compute coriolis
coriolis_parameter = section.getfloat('coriolis_parameter')
Expand Down Expand Up @@ -235,7 +237,7 @@ def _plot(self, ds):
ds['totalColThickness'] = ds['ssh']
ds['totalColThickness'].values = \
ds['layerThickness'].sum(dim='nVertLevels')
tol=1e-10
tol = 1e-10
plotter.plot_horiz_series(ds.landIceMask,
'landIceMask', 'landIceMask',
True)
Expand All @@ -253,40 +255,40 @@ def _plot(self, ds):
True, vmin=0, vmax=700)
plotter.plot_horiz_series(ds.ssh + ds.bottomDepth,
'H', 'H', True,
vmin=min_column_thickness+tol, vmax=700,
vmin=min_column_thickness + tol, vmax=700,
cmap_set_under='r', cmap_scale='log')
plotter.plot_horiz_series(ds.totalColThickness,
'totalColThickness', 'totalColThickness',
True, vmin=min_column_thickness + 1e-10,
vmax=700, cmap_set_under='r')
plotter.plot_horiz_series(ds.landIceFraction,
'landIceFraction', 'landIceFraction',
True, vmin=0+tol, vmax=1-tol,
True, vmin=0 + tol, vmax=1 - tol,
cmap='cmo.balance',
cmap_set_under='k', cmap_set_over='r')
plotter.plot_horiz_series(ds.landIceFloatingFraction,
'landIceFloatingFraction',
'landIceFloatingFraction',
True, vmin=0+tol, vmax=1-tol,
True, vmin=0 + tol, vmax=1 - tol,
cmap='cmo.balance',
cmap_set_under='k', cmap_set_over='r')
plotter.plot_horiz_series(ds.landIceGroundedFraction,
'landIceGroundedFraction',
'landIceGroundedFraction',
True, vmin=0+tol, vmax=1-tol,
True, vmin=0 + tol, vmax=1 - tol,
cmap='cmo.balance',
cmap_set_under='k', cmap_set_over='r')
plotter.plot_horiz_series(ds.oceanFracObserved,
'oceanFracObserved', 'oceanFracObserved',
True, vmin=0+tol, vmax=1-tol,
True, vmin=0 + tol, vmax=1 - tol,
cmap='cmo.balance',
cmap_set_under='k', cmap_set_over='r')
plotter.plot_layer_interfaces()

plotter.plot_3d_field_top_bot_section(
ds.layerThickness, nameInTitle='layerThickness',
prefix='h', units='m',
vmin=min_column_thickness + 1e-10, vmax=50,
vmin=min_column_thickness + tol, vmax=50,
cmap='cmo.deep_r', cmap_set_under='r')

plotter.plot_3d_field_top_bot_section(
Expand Down

0 comments on commit f904806

Please sign in to comment.