Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exp_2x1day.build_and_run()
exp_2x1day.force_run()
# Now do a single 2 day run
exp_2day = setup_exp_from_base('1deg_jra55_iaf', '1deg_jra55_iaf_2day')
# Reconfigure
with open(exp_2day.accessom2_config) as f:
nml = f90nml.read(f)
nml['date_manager_nml']['restart_period'] = [0, 0, 172800]
nml.write(exp_2day.accessom2_config, force=True)
# Don't use Redsea fix - this breaks reproducibility
# https://github.com/COSIMA/access-om2/issues/124
with open(exp_2day.ocean_config) as f:
nml = f90nml.read(f)
nml['auscom_ice_nml']['redsea_gulfbay_sfix'] = False
nml.write(exp_2day.ocean_config, force=True)
# Run once.
exp_2day.build_and_run()
# Now compare the output between our two short and one long run.
two_shrt = self.checksums_to_list(exp_2x1day.accessom2_out_000)
two_shrt = two_shrt + self.checksums_to_list(exp_2x1day.accessom2_out_001)
one_long = self.checksums_to_list(exp_2day.accessom2_out_000)
assert len(one_long) > 0
for line in one_long:
if line not in two_shrt:
def test_uppercase(self):
test_nml = f90nml.read('types.nml')
test_nml.uppercase = True
self.assert_write(test_nml, 'types_uppercase.nml')
self.assertRaises(TypeError, setattr, test_nml, 'uppercase', 'xyz')
def test_extern_cmt(self):
test_nml = f90nml.read('extern_cmt.nml')
self.assertEqual(self.extern_cmt_nml, test_nml)
def test_index_syntax(self):
self.assertRaises(ValueError, f90nml.read, 'index_empty.nml')
self.assertRaises(ValueError, f90nml.read, 'index_bad.nml')
self.assertRaises(ValueError, f90nml.read, 'index_bad_start.nml')
self.assertRaises(ValueError, f90nml.read, 'index_empty_end.nml')
self.assertRaises(ValueError, f90nml.read, 'index_bad_end.nml')
self.assertRaises(ValueError, f90nml.read, 'index_empty_stride.nml')
self.assertRaises(ValueError, f90nml.read, 'index_bad_stride.nml')
self.assertRaises(ValueError, f90nml.read, 'index_zero_stride.nml')
def test_print_group(self):
nml = f90nml.read('types.nml')
stdout = StringIO()
print(nml['types_nml'], file=stdout)
stdout.seek(0)
source_str = stdout.read().rstrip('\n')
stdout.close()
target_str = repr(nml['types_nml'])
self.assertEqual(source_str, target_str)
def test_float_format(self):
test_nml = f90nml.read('float.nml')
test_nml.float_format = '.3f'
self.assert_write(test_nml, 'float_format.nml')
self.assertRaises(TypeError, setattr, test_nml, 'float_format', 123)
def test_vector_default_index(self):
test_nml = f90nml.read('vector.nml')
test_nml.default_start_index = 2
self.assertEqual(self.vector_nml, test_nml)
self.assert_write(test_nml, 'vector_default_idx.nml')
if ice_ts:
model.set_oasis_timestep(ice_ts)
# Set ACCESS coupler timesteps
input_ice_path = os.path.join(model.work_path, 'input_ice.nml')
input_ice = f90nml.read(input_ice_path)
input_ice['coupling_nml']['dt_cpl_io'] = t_step
input_ice.write(input_ice_path, force=True)
elif model.model_type == 'matm':
input_atm_path = os.path.join(model.work_path, 'input_atm.nml')
input_atm = f90nml.read(input_atm_path)
input_atm['coupling']['dt_atm'] = t_step
input_atm.write(input_atm_path, force=True)
elif model.model_type == 'mom':
input_nml_path = os.path.join(model.work_path, 'input.nml')
input_nml = f90nml.read(input_nml_path)
input_nml['auscom_ice_nml']['dt_cpl'] = t_step
input_nml['ocean_solo_nml']['dt_cpld'] = t_step
input_nml.write(input_nml_path, force=True)
###for WCOSS
### /naqfc/noscrub/Barry.Baker/anaconda2/bin/python
import f90nml
from numpy import sort
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
from numpy import unique,sort
from datetime import datetime, timedelta
import pandas as pd
from glob import glob
from verify_airnow import verify_airnow
import sys
import utils
#Read the Namelist
nml = f90nml.read('comparesim.namelist')
base = nml['files']['basename']
gridcro = nml['files']['gridcro']
datapath = nml['files']['data_dir']
interp = nml['interp']['method']
neighbors = nml['interp']['neighbors']
radius = nml['interp']['radius_of_influence']
#airnow user and pass
usr = 'Barry.Baker'
p = 'p00pST!ck123'
#INTERP SIMULATIONS TO OBSERVATIONS
if nml['files']['sim1'].lower() != 'none':
print 'Pairing Sim1...'
print ' '
if nml['files']['sim1'].lower()[-4:] =='.hdf':
def set_access_timestep(self, t_step):
# TODO: Figure out some way to move this to the ACCESS driver
# Re-read ice timestep and move this over there
self.set_local_timestep(t_step)
input_ice_path = os.path.join(self.work_path, 'input_ice.nml')
input_ice = f90nml.read(input_ice_path)
input_ice['coupling_nml']['dt_cice'] = t_step
input_ice.write(input_ice_path, force=True)