Example 1: load a time series at one location by accessing netCDF4 files stored on /results or /results2¶
In [2]:
%%timestart=dt.datetime(2017,3,1)end=dt.datetime(2017,9,30)# the code called below (evaltools.index_model_files) includes the end date # in the values returnedbasedir='/results/SalishSea/nowcast-green.201812/'nam_fmt='nowcast'flen=1# files contain 1 day of data eachftype='ptrc_T'# load bio filestres=24# 1: hourly resolution; 24: daily resolution <- try changing to 1 and loading hourly dataflist=et.index_model_files(start,end,basedir,nam_fmt,flen,ftype,tres)# flist contains paths: file pathes; t_0 timestemp of start of each file; t_n: timestamp of start of next fileprint(flist)
CPU times: user 1min 8s, sys: 11.2 s, total: 1min 19s
Wall time: 3min 28s
Out[7]:
(17226.5, 17439.5)
In [ ]:
# Adjust date format displayfig,ax=plt.subplots(1,1,figsize=(12,3))ax.plot(tt,diat,'c-',label='diatoms')ax.plot(tt,micZ,'-',color='darkorange',label='microzooplankton')ax.legend(loc=2);ax.set_ylabel('Concentration ($\mu$M N)')ax.set_xlim(tt[0],tt[-1])yearsFmt=mdates.DateFormatter('%d %b')ax.xaxis.set_major_formatter(yearsFmt)ax.set_title('March 2017')
start=dt.datetime(2017,3,1)end=dt.datetime(2017,3,5)# the code called below (evaltools.index_model_files) includes the end date # in the values returnedtres=1# 1: hourly resolution; 24: daily resolution <- try changing to 1 and loading hourly dataflist=et.index_model_files(start,end,basedir,nam_fmt,flen,ftype,tres)# flist contains paths: file pathes; t_0 timestemp of start of each file; t_n: timestamp of start of next fileflist['paths'][0]
If you use this dataset in your research,
please reference it with wording similar to the example below,
and include citations of the publications below.
Inclusion of the date(s) when you downloaded the dataset,
and the dataset id help to ensure reproducibility of your work.
Reference wording:
3d SMELT biological model field values from the SalishSeaCast model
(Soontiens et al, 2016; Moore-Maley et al, 2016; Soontiens and Allen, 2017, Olson et al, 2020)
were downloaded from their ERDDAP server
(https://salishsea.eos.ubc.ca/erddap/)
on DATE from dataset ubcSSg3DBiologyFields1hV19-05.
Citations:
Soontiens, N., Allen, S., Latornell, D., Le Souef, K., Machuca, I., Paquin, J.-P., Lu, Y., Thompson, K., Korabel, V., 2016.
Storm surges in the Strait of Georgia simulated with a regional model. Atmosphere-Ocean 54 1-21.
https://dx.doi.org/10.1080/07055900.2015.1108899
Moore-Maley, B. L., Allen, S. E., and IansonD., 2016.
Locally-driven interannual variability of near-surface pH and ΩA in the Strait of Georgia.
J. Geophys. Res. Oceans, 121(3), 1600–1625.
https://dx.doi.org/10.1002/2015JC011118
Soontiens, N. and Allen, S., 2017.
Modelling sensitivities to mixing and advection in a sill-basin estuarine system. Ocean Modelling, 112, 17-32.
https://dx.doi.org/10.1016/j.ocemod.2017.02.008
Olson, E. M., Allen, S. E., Do, Vy, Dunphy, M., and Ianson, D., 2020. Assessment of Nutrient Supply by a Tidal Jet in the Northern Strait of Georgia Based on a Biogeochemical Model. J. Geophys. Res. Oceans, 125(8). https://doi.org/10.1029/2019JC015766
The Salish Sea MEOPAR NEMO model results are copyright
by the Salish Sea MEOPAR Project Contributors and The University of British Columbia.
They are licensed under the Apache License, Version 2.0. https://www.apache.org/licenses/LICENSE-2.0
project :
Salish Sea MEOPAR NEMO Model
sourceUrl :
(local files)
standard_name_vocabulary :
CF Standard Name Table v29
summary :
Green, Salish Sea, 3d Biology Fields, Hourly, v19-05
3d SMELT biological model field values averaged over 1 hour intervals
from Salish Sea NEMO model runs with physics, biology and chemistry. The values are calculated for the entire model grid
that includes the Juan de Fuca Strait, the Strait of Georgia, Puget Sound,
and Johnstone Strait on the coasts of Washington State and British Columbia.
The time values are UTC.
They are the centre of the intervals over which the calculated model results are averaged.
Geo-location and depth data for the Salish Sea NEMO model grid are available in the ubcSSnBathymetry2V17-02 dataset.
v17-02: Micromolar concentrations of ammonium, biogenic silicon, ciliates (mesodinium rubrum),
diatoms, dissolved organic nitrogen, flagellates (nanophytoplankton), mesozooplankton, microzooplankton,
nitrate, particulate organic nitrogen, silicon.
Fraser River water turbidity tracer.
NEMO-3.6; ubcSSnBathymetryV17-02 bathymetry; see infoUrl link for full details.
v18-06: NEMO-3.6 SalishSeaCast-201806 configuration; ubcSSnBathymetryV17-02 bathymetry;
see infoUrl link for full details.
v18-12: NEMO-3.6 SalishSeaCast-201812 configuration; ubcSSnBathymetryV17-02 bathymetry;
see infoUrl link for full details.
v19-05: NEMO-3.6 SalishSeaCast-201905 configuration; ubcSSnBathymetryV17-02 bathymetry;
see infoUrl link for full details.
testOutOfDate :
now-16hours
time_coverage_end :
2021-01-20T23:30:00Z
time_coverage_start :
2007-01-01T00:30:00Z
timeStamp :
2021-Jan-20 19:28:54 GMT
title :
Green, Salish Sea, 3d Biology Fields, Hourly, v19-05
dfFra=pd.read_csv('/ocean/eolson/MEOPAR/obs/ECRivers/Flow/FraserHopeDaily__Dec-2-2020_10_31_05PM.csv',skiprows=1)# the original file contains both flow and water level information in the same field (Value)# keep only the flow data, where PARAM=1 (drop PARAM=2 values)# flow units are m3/sdfFra.drop(dfFra.loc[dfFra.PARAM==2].index,inplace=True)
In [25]:
# rename 'Value' column to 'Flow' now that we have removed all the water level rowsdfFra.rename(columns={'Value':'Flow'},inplace=True)
In [26]:
dfFra
Out[26]:
ID
PARAM
YEAR
DD
Flow
SYM
0
08MF005
1
1912
61
538.0
NaN
1
08MF005
1
1912
62
538.0
NaN
2
08MF005
1
1912
63
538.0
NaN
3
08MF005
1
1912
64
538.0
NaN
4
08MF005
1
1912
65
538.0
NaN
...
...
...
...
...
...
...
39016
08MF005
1
2018
360
1090.0
NaN
39017
08MF005
1
2018
361
1050.0
NaN
39018
08MF005
1
2018
362
1030.0
NaN
39019
08MF005
1
2018
363
1120.0
NaN
39020
08MF005
1
2018
364
1170.0
NaN
39021 rows × 6 columns
In [27]:
# no time information so use dt.datedfFra['Date']=[dt.date(iyr,1,1)+dt.timedelta(days=idd-1)foriyr,iddinzip(dfFra['YEAR'],dfFra['DD'])]
In [28]:
dfFra.head(2)
Out[28]:
ID
PARAM
YEAR
DD
Flow
SYM
Date
0
08MF005
1
1912
61
538.0
NaN
1912-03-01
1
08MF005
1
1912
62
538.0
NaN
1912-03-02
In [29]:
# select portion of dataframe in desired date rangedfFra2=dfFra.loc[(dfFra.Date>=newstart.date())&(dfFra.Date<=newend.date())]
In [33]:
fig,ax=plt.subplots(1,1,figsize=(12,3))ax.plot(dfFra2['Date'],dfFra2['Flow'],'c-')ax.set_ylabel('Flow (m$^3$s$^{-1}$)')ax.set_title('Fraser Flow at Hope')