{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import netCDF4 as nc\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "from salishsea_tools import evaltools as et\n", "import datetime as dt\n", "import pandas as pd\n", "\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "start=dt.datetime(2015,1,1)\n", "end=dt.datetime(2019,1,1)\n", "dataDFO=et.loadDFO(datelims=(start,end))" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "dates=dataDFO.loc[:,['dtUTC']].sort_values(by=['dtUTC']).drop_duplicates().reset_index()" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "dates['filename']=None" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "PATH= '/results/SalishSea/nowcast-green.201812/'\n", "flen=1\n", "namfmt='nowcast'\n", "fdict={'ptrc_T':1,'grid_T':1}\n", "ftype='ptrc_T'" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "flist=et.index_model_files(start,end,PATH,namfmt,flen,ftype,1)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "def _nextfile_bin(idt,flist):\n", " frow=flist.loc[(flist.t_0<=idt)&(flist.t_n>idt)]\n", " fid=frow['paths'].values[0]\n", " fend=frow['t_n'].values[0]\n", " return fid, fend" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "for ind, row in dates.iterrows():\n", " if ind==0: # load first files\n", " fid,fend=_nextfile_bin(row['dtUTC'],flist)\n", " if row['dtUTC']>=fend:\n", " fid,fend=_nextfile_bin(row['dtUTC'],flist)\n", " dates.at[ind, 'filename'] = fid[40:]" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "files=dates['filename'].drop_duplicates() " ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "11feb15/SalishSea_1h_20150211_20150211_ptrc_T.nc\n", "06mar15/SalishSea_1h_20150306_20150306_ptrc_T.nc\n", "02apr15/SalishSea_1h_20150402_20150402_ptrc_T.nc\n", "03apr15/SalishSea_1h_20150403_20150403_ptrc_T.nc\n", "04apr15/SalishSea_1h_20150404_20150404_ptrc_T.nc\n", "05apr15/SalishSea_1h_20150405_20150405_ptrc_T.nc\n", "07apr15/SalishSea_1h_20150407_20150407_ptrc_T.nc\n", "27may15/SalishSea_1h_20150527_20150527_ptrc_T.nc\n", "06jun15/SalishSea_1h_20150606_20150606_ptrc_T.nc\n", "07jun15/SalishSea_1h_20150607_20150607_ptrc_T.nc\n", "25jun15/SalishSea_1h_20150625_20150625_ptrc_T.nc\n", "26jun15/SalishSea_1h_20150626_20150626_ptrc_T.nc\n", "27jun15/SalishSea_1h_20150627_20150627_ptrc_T.nc\n", "14sep15/SalishSea_1h_20150914_20150914_ptrc_T.nc\n", "30sep15/SalishSea_1h_20150930_20150930_ptrc_T.nc\n", "01oct15/SalishSea_1h_20151001_20151001_ptrc_T.nc\n", "02oct15/SalishSea_1h_20151002_20151002_ptrc_T.nc\n", "15mar16/SalishSea_1h_20160315_20160315_ptrc_T.nc\n", "16mar16/SalishSea_1h_20160316_20160316_ptrc_T.nc\n", "17mar16/SalishSea_1h_20160317_20160317_ptrc_T.nc\n", "18mar16/SalishSea_1h_20160318_20160318_ptrc_T.nc\n", "19mar16/SalishSea_1h_20160319_20160319_ptrc_T.nc\n", "20mar16/SalishSea_1h_20160320_20160320_ptrc_T.nc\n", "22apr16/SalishSea_1h_20160422_20160422_ptrc_T.nc\n", "23apr16/SalishSea_1h_20160423_20160423_ptrc_T.nc\n", "24apr16/SalishSea_1h_20160424_20160424_ptrc_T.nc\n", "25apr16/SalishSea_1h_20160425_20160425_ptrc_T.nc\n", "26apr16/SalishSea_1h_20160426_20160426_ptrc_T.nc\n", "28apr16/SalishSea_1h_20160428_20160428_ptrc_T.nc\n", "29apr16/SalishSea_1h_20160429_20160429_ptrc_T.nc\n", "30apr16/SalishSea_1h_20160430_20160430_ptrc_T.nc\n", "01may16/SalishSea_1h_20160501_20160501_ptrc_T.nc\n", "02may16/SalishSea_1h_20160502_20160502_ptrc_T.nc\n", "25may16/SalishSea_1h_20160525_20160525_ptrc_T.nc\n", "04jun16/SalishSea_1h_20160604_20160604_ptrc_T.nc\n", "06jun16/SalishSea_1h_20160606_20160606_ptrc_T.nc\n", "16jun16/SalishSea_1h_20160616_20160616_ptrc_T.nc\n", "17jun16/SalishSea_1h_20160617_20160617_ptrc_T.nc\n", "18jun16/SalishSea_1h_20160618_20160618_ptrc_T.nc\n", "19jun16/SalishSea_1h_20160619_20160619_ptrc_T.nc\n", "20jun16/SalishSea_1h_20160620_20160620_ptrc_T.nc\n", "23jun16/SalishSea_1h_20160623_20160623_ptrc_T.nc\n", "24jun16/SalishSea_1h_20160624_20160624_ptrc_T.nc\n", "25jun16/SalishSea_1h_20160625_20160625_ptrc_T.nc\n", "26jun16/SalishSea_1h_20160626_20160626_ptrc_T.nc\n", "27jun16/SalishSea_1h_20160627_20160627_ptrc_T.nc\n", "28jun16/SalishSea_1h_20160628_20160628_ptrc_T.nc\n", "05jul16/SalishSea_1h_20160705_20160705_ptrc_T.nc\n", "21jul16/SalishSea_1h_20160721_20160721_ptrc_T.nc\n", "22jul16/SalishSea_1h_20160722_20160722_ptrc_T.nc\n", "23jul16/SalishSea_1h_20160723_20160723_ptrc_T.nc\n", "24jul16/SalishSea_1h_20160724_20160724_ptrc_T.nc\n", "25jul16/SalishSea_1h_20160725_20160725_ptrc_T.nc\n", "27jul16/SalishSea_1h_20160727_20160727_ptrc_T.nc\n", "17aug16/SalishSea_1h_20160817_20160817_ptrc_T.nc\n", "18aug16/SalishSea_1h_20160818_20160818_ptrc_T.nc\n", "11sep16/SalishSea_1h_20160911_20160911_ptrc_T.nc\n", "12sep16/SalishSea_1h_20160912_20160912_ptrc_T.nc\n", "23sep16/SalishSea_1h_20160923_20160923_ptrc_T.nc\n", "24sep16/SalishSea_1h_20160924_20160924_ptrc_T.nc\n", "25sep16/SalishSea_1h_20160925_20160925_ptrc_T.nc\n", "26sep16/SalishSea_1h_20160926_20160926_ptrc_T.nc\n", "27sep16/SalishSea_1h_20160927_20160927_ptrc_T.nc\n", "31oct16/SalishSea_1h_20161031_20161031_ptrc_T.nc\n", "01nov16/SalishSea_1h_20161101_20161101_ptrc_T.nc\n", "02nov16/SalishSea_1h_20161102_20161102_ptrc_T.nc\n", "03nov16/SalishSea_1h_20161103_20161103_ptrc_T.nc\n", "04nov16/SalishSea_1h_20161104_20161104_ptrc_T.nc\n", "19feb17/SalishSea_1h_20170219_20170219_ptrc_T.nc\n", "20feb17/SalishSea_1h_20170220_20170220_ptrc_T.nc\n", "07mar17/SalishSea_1h_20170307_20170307_ptrc_T.nc\n", "08mar17/SalishSea_1h_20170308_20170308_ptrc_T.nc\n", "09mar17/SalishSea_1h_20170309_20170309_ptrc_T.nc\n", "20mar17/SalishSea_1h_20170320_20170320_ptrc_T.nc\n", "21mar17/SalishSea_1h_20170321_20170321_ptrc_T.nc\n", "25mar17/SalishSea_1h_20170325_20170325_ptrc_T.nc\n", "26mar17/SalishSea_1h_20170326_20170326_ptrc_T.nc\n", "09apr17/SalishSea_1h_20170409_20170409_ptrc_T.nc\n", "10apr17/SalishSea_1h_20170410_20170410_ptrc_T.nc\n", "11apr17/SalishSea_1h_20170411_20170411_ptrc_T.nc\n", "12apr17/SalishSea_1h_20170412_20170412_ptrc_T.nc\n", "13apr17/SalishSea_1h_20170413_20170413_ptrc_T.nc\n", "15apr17/SalishSea_1h_20170415_20170415_ptrc_T.nc\n", "16apr17/SalishSea_1h_20170416_20170416_ptrc_T.nc\n", "17apr17/SalishSea_1h_20170417_20170417_ptrc_T.nc\n", "18apr17/SalishSea_1h_20170418_20170418_ptrc_T.nc\n", "19apr17/SalishSea_1h_20170419_20170419_ptrc_T.nc\n", "22apr17/SalishSea_1h_20170422_20170422_ptrc_T.nc\n", "23apr17/SalishSea_1h_20170423_20170423_ptrc_T.nc\n", "24apr17/SalishSea_1h_20170424_20170424_ptrc_T.nc\n", "25apr17/SalishSea_1h_20170425_20170425_ptrc_T.nc\n", "21may17/SalishSea_1h_20170521_20170521_ptrc_T.nc\n", "22may17/SalishSea_1h_20170522_20170522_ptrc_T.nc\n", "23may17/SalishSea_1h_20170523_20170523_ptrc_T.nc\n", "24may17/SalishSea_1h_20170524_20170524_ptrc_T.nc\n", "02jun17/SalishSea_1h_20170602_20170602_ptrc_T.nc\n", "03jun17/SalishSea_1h_20170603_20170603_ptrc_T.nc\n", "05jun17/SalishSea_1h_20170605_20170605_ptrc_T.nc\n", "06jun17/SalishSea_1h_20170606_20170606_ptrc_T.nc\n", "07jun17/SalishSea_1h_20170607_20170607_ptrc_T.nc\n", "08jun17/SalishSea_1h_20170608_20170608_ptrc_T.nc\n", "19jun17/SalishSea_1h_20170619_20170619_ptrc_T.nc\n", "22jun17/SalishSea_1h_20170622_20170622_ptrc_T.nc\n", "23jun17/SalishSea_1h_20170623_20170623_ptrc_T.nc\n", "24jun17/SalishSea_1h_20170624_20170624_ptrc_T.nc\n", "25jun17/SalishSea_1h_20170625_20170625_ptrc_T.nc\n", "26jun17/SalishSea_1h_20170626_20170626_ptrc_T.nc\n", "28jun17/SalishSea_1h_20170628_20170628_ptrc_T.nc\n", "30jun17/SalishSea_1h_20170630_20170630_ptrc_T.nc\n", "01jul17/SalishSea_1h_20170701_20170701_ptrc_T.nc\n", "12jul17/SalishSea_1h_20170712_20170712_ptrc_T.nc\n", "13jul17/SalishSea_1h_20170713_20170713_ptrc_T.nc\n", "14jul17/SalishSea_1h_20170714_20170714_ptrc_T.nc\n", "15jul17/SalishSea_1h_20170715_20170715_ptrc_T.nc\n", "31jul17/SalishSea_1h_20170731_20170731_ptrc_T.nc\n", "02aug17/SalishSea_1h_20170802_20170802_ptrc_T.nc\n", "03aug17/SalishSea_1h_20170803_20170803_ptrc_T.nc\n", "04aug17/SalishSea_1h_20170804_20170804_ptrc_T.nc\n", "14aug17/SalishSea_1h_20170814_20170814_ptrc_T.nc\n", "15aug17/SalishSea_1h_20170815_20170815_ptrc_T.nc\n", "16aug17/SalishSea_1h_20170816_20170816_ptrc_T.nc\n", "17aug17/SalishSea_1h_20170817_20170817_ptrc_T.nc\n", "18aug17/SalishSea_1h_20170818_20170818_ptrc_T.nc\n", "29aug17/SalishSea_1h_20170829_20170829_ptrc_T.nc\n", "30aug17/SalishSea_1h_20170830_20170830_ptrc_T.nc\n", "31aug17/SalishSea_1h_20170831_20170831_ptrc_T.nc\n", "01sep17/SalishSea_1h_20170901_20170901_ptrc_T.nc\n", "10sep17/SalishSea_1h_20170910_20170910_ptrc_T.nc\n", "11sep17/SalishSea_1h_20170911_20170911_ptrc_T.nc\n", "05oct17/SalishSea_1h_20171005_20171005_ptrc_T.nc\n", "06oct17/SalishSea_1h_20171006_20171006_ptrc_T.nc\n", "07oct17/SalishSea_1h_20171007_20171007_ptrc_T.nc\n", "08oct17/SalishSea_1h_20171008_20171008_ptrc_T.nc\n", "09oct17/SalishSea_1h_20171009_20171009_ptrc_T.nc\n", "03feb18/SalishSea_1h_20180203_20180203_ptrc_T.nc\n", "04feb18/SalishSea_1h_20180204_20180204_ptrc_T.nc\n", "05feb18/SalishSea_1h_20180205_20180205_ptrc_T.nc\n", "06feb18/SalishSea_1h_20180206_20180206_ptrc_T.nc\n", "07feb18/SalishSea_1h_20180207_20180207_ptrc_T.nc\n", "03mar18/SalishSea_1h_20180303_20180303_ptrc_T.nc\n", "04mar18/SalishSea_1h_20180304_20180304_ptrc_T.nc\n", "05mar18/SalishSea_1h_20180305_20180305_ptrc_T.nc\n", "06mar18/SalishSea_1h_20180306_20180306_ptrc_T.nc\n", "07mar18/SalishSea_1h_20180307_20180307_ptrc_T.nc\n", "07apr18/SalishSea_1h_20180407_20180407_ptrc_T.nc\n", "08apr18/SalishSea_1h_20180408_20180408_ptrc_T.nc\n", "09apr18/SalishSea_1h_20180409_20180409_ptrc_T.nc\n", "10apr18/SalishSea_1h_20180410_20180410_ptrc_T.nc\n", "11apr18/SalishSea_1h_20180411_20180411_ptrc_T.nc\n", "09may18/SalishSea_1h_20180509_20180509_ptrc_T.nc\n", "17may18/SalishSea_1h_20180517_20180517_ptrc_T.nc\n", "18may18/SalishSea_1h_20180518_20180518_ptrc_T.nc\n" ] } ], "source": [ "for el in files:\n", " print(el)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python (py38_ct)", "language": "python", "name": "py38_ct" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.2" } }, "nbformat": 4, "nbformat_minor": 2 }