import numpy as np
from matplotlib import pyplot as plt
import netCDF4 as nc
import re
import shutil
%matplotlib inline
src='/ocean/eolson/MEOPAR/northernNO3PaperCalcs/bioModel/runFiles/01may15/SalishSea_01153440_restart_trc.nc'
dst='/ocean/eolson/MEOPAR/northernNO3PaperCalcs/bioModel/runFiles/01may15/SalishSea_01153440_restart_trc_SinkTest.nc'
shutil.copy(src, dst)
'/ocean/eolson/MEOPAR/northernNO3PaperCalcs/bioModel/runFiles/01may15/SalishSea_01153440_restart_trc_SinkTest.nc'
f=nc.Dataset(dst,'r+')
print(f.variables.keys())
odict_keys(['nav_lon', 'nav_lat', 'nav_lev', 'time_counter', 'kt', 'ndastp', 'adatrj', 'rnf_pis_NO3_b', 'rnf_pis_NH4_b', 'rnf_pis_Si_b', 'rnf_pis_DIAT_b', 'rnf_pis_PHY_b', 'rnf_pis_MYRI_b', 'rnf_pis_MICZ_b', 'rnf_pis_DON_b', 'rnf_pis_PON_b', 'rnf_pis_bSi_b', 'rnf_pis_TRA_b', 'rnf_pis_DIC_b', 'rnf_pis_TA_b', 'rnf_pis_O2_b', 'sbc_NO3_b', 'sbc_NH4_b', 'sbc_Si_b', 'sbc_DIAT_b', 'sbc_PHY_b', 'sbc_MYRI_b', 'sbc_MICZ_b', 'sbc_DON_b', 'sbc_PON_b', 'sbc_bSi_b', 'sbc_TRA_b', 'sbc_DIC_b', 'sbc_TA_b', 'sbc_O2_b', 'sbc_MYTRC1_b', 'rdttrc1', 'TRNNO3', 'TRNNH4', 'TRNSi', 'TRNDIAT', 'TRNPHY', 'TRNMYRI', 'TRNMICZ', 'TRNDON', 'TRNPON', 'TRNbSi', 'TRNTRA', 'TRNDIC', 'TRNTA', 'TRNO2', 'TRNMYTRC1', 'TRBNO3', 'TRBNH4', 'TRBSi', 'TRBDIAT', 'TRBPHY', 'TRBMYRI', 'TRBMICZ', 'TRBDON', 'TRBPON', 'TRBbSi', 'TRBTRA', 'TRBDIC', 'TRBTA', 'TRBO2', 'TRBMYTRC1'])
f.variables['TRNDIAT']
<class 'netCDF4._netCDF4.Variable'> float64 TRNDIAT(t, z, y, x) unlimited dimensions: t current shape = (1, 40, 898, 398) filling on, default _FillValue of 9.969209968386869e+36 used
for var in ('TRNNO3', 'TRNNH4', 'TRNSi', 'TRNDIAT', 'TRNPHY', 'TRNMYRI', 'TRNMICZ',
'TRNDON', 'TRNPON', 'TRNbSi', 'TRNTRA', 'TRNDIC', 'TRNTA', 'TRNO2',
'TRNMYTRC1', 'TRBNO3', 'TRBNH4', 'TRBSi', 'TRBDIAT', 'TRBPHY', 'TRBMYRI',
'TRBMICZ', 'TRBDON', 'TRBPON', 'TRBbSi', 'TRBTRA', 'TRBDIC', 'TRBTA', 'TRBO2',
'TRBMYTRC1'):
f.variables[var][:]=0.0
f.variables['TRBNO3'][:,5,:,:]=100.0
f.variables['TRNNO3'][:,5,:,:]=100.0
f.variables['TRBDIAT'][:,5,:,:]=100.0
f.variables['TRNDIAT'][:,5,:,:]=100.0
f.variables['TRBbSi'][:,5,:,:]=100.0
f.variables['TRNbSi'][:,5,:,:]=100.0
f.variables['TRBPON'][:,33,:,:]=100.0
f.variables['TRNPON'][:,33,:,:]=100.0
np.max(f.variables['TRNPHY']), np.min(f.variables['TRNPHY'])
(0.0, 0.0)
np.max(f.variables['TRNMYRI']), np.min(f.variables['TRNMYRI'])
(0.0, 0.0)
np.max(f.variables['sbc_MYRI_b']), np.min(f.variables['sbc_MYRI_b'])
(0.0, 0.0)
f.close()
f=nc.Dataset(dst)
np.max(f.variables['TRNPHY']), np.min(f.variables['TRNPHY'])
(0.0, 0.0)
np.max(f.variables['TRNMYRI']), np.min(f.variables['TRNMYRI'])
(0.0, 0.0)
np.max(f.variables['TRBMYRI']), np.min(f.variables['TRBMYRI'])
(0.0, 0.0)
f.close()