diff --git a/.cmtbSettings b/.cmtbSettings index e4c641b..c58123d 100644 --- a/.cmtbSettings +++ b/.cmtbSettings @@ -3,6 +3,7 @@ # #################################### # +slack: None runFlag: true analyzeFlag: true plotFlag: false @@ -14,6 +15,7 @@ hpcSettings: hpcCores: 36 hpcNodes: 1 testName: '' +hotStartFlag: false logfileLoc: ./data/logs workingDirectory: ./data # this is the directory where simulation files and QA/QC plots are made and existing architecture takes over netCDFdir: ./thredds_data # this is the base directory where netCDF files are output diff --git a/README.md b/README.md index bf2fc5e..5fdfab8 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ The test bed is established at the USACE CHL Field REsearch Facility in Duck, No - conda install conda install -c conda-forge cartopy - * netCDF4, pyproj, utm, wavespectra, progressbar, opencv-python + * netCDF4, pyproj, utm (cf), wavespectra (cf), progressbar (cf), opencv (cf) - there's likely more, please add as you find!! :-[] diff --git a/frontback/frontBackNEW.py b/frontback/frontBackNEW.py index f6325d2..7c1659e 100644 --- a/frontback/frontBackNEW.py +++ b/frontback/frontBackNEW.py @@ -4,7 +4,6 @@ from getdatatestbed.getDataFRF import getDataTestBed import datetime as DT import os, glob, makenc, sys, shutil -from subprocess import check_output import netCDF4 as nc import numpy as np import plotting.operationalPlots as oP @@ -32,6 +31,8 @@ def ww3simSetup(startTimeString, inputDict, allWind , allWL, allWave, wrr): """ # begin by setting up input parameters + import pdb + pdb.set_trace() simulationDuration = int(inputDict.get('simulationDuration', 24)) plotFlag = inputDict.get('plotFlag', True) @@ -69,7 +70,7 @@ def ww3simSetup(startTimeString, inputDict, allWind , allWL, allWave, wrr): assert rawspec is not None, "\n++++\nThere's No Wave data between %s and %s \n++++\n" % (startTime, endTime) # use generated time lists for these to provide accurate temporal values _, waveTimeList, wlTimeList, _, windTimeList = prepdata.createDifferentTimeLists(startTime, endTime, rawspec, rawWL, - rawWind=rawwind) + rawWind=rawwind,simTs=30*60) nFreq = np.size(rawspec['wavefreqbin']) # rotate and lower resolution of directional wave spectra wavepacket = prepdata.prep_spec(rawspec, version_prefix, datestr=dateString, plot=plotFlag, full=full, deltaangle=10, @@ -208,8 +209,6 @@ class objects as listed below: # _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ # establishing the resolution of the input datetime # try: - projectStart = DT.datetime.strptime(startTime, '%Y-%m-%dT%H:%M:%SZ') - projectEnd = DT.datetime.strptime(inputDict['endTime'], '%Y-%m-%dT%H:%M:%SZ') dateString = wrr.dateString # a string for file names # _____________________________________________________________________________ @@ -221,7 +220,11 @@ class objects as listed below: if postProcessingDict['phaseResolved'] == True: spatialPostProcessed = postData.processNLwave(spatialData, wrr=wrr, ncFilesOnly=False) pointPostProcessed = None + elif postProcessingDict['phaseAveraged'] == True: + spatialPostProcessed = postData.processPAwave(spatialData, wrr=wrr, ncFilesOnly=False) + pointPostProcessed = None # this needs to be developed else: + # place holder for new development spatialPostProcessed, pointPostProcessed = someFunctionPostProcesing(spatialData, pointData) # __________________________2. make netCDF Files________________________________ @@ -254,10 +257,24 @@ class objects as listed below: elif postProcessingDict['phaseAveraged'] is True: variables = ncfile.variables.keys() - for var in variables: - if var in ['waveHs', 'waveDm', 'waveTm'] and plotFlag is True: - plotOutFname = 'test.png' - oP.unstructuredSpatialPlot(plotOutFname, fieldNc=ncfile, variable=var) + if postProcessingDict['gridType'] == 'unstructured': + for var in variables: + if var in ['waveHs', 'waveDm', 'waveTm'] and plotFlag is True: + plotOutFname = 'test.png' + oP.unstructuredSpatialPlot(plotOutFname, fieldNc=ncfile, variable=var) + if postProcessingDict['gridType'] == '1D': + for var in ['aveN', 'aveE', 'waveHs']: + for t, tt in enumerate(ncfile['time'][:]): + plotOutFname = os.path.join(wrr.plottingDirectory, f"CMTB_{wrr.modelName}_{var}_" \ + f"{nc.num2date(tt, ncfile['time'].units).strftime('%Y%m%dT%H%M%SZ')}.png") + oP.plotWaveProfile(ncfile['xFRF'][:], ncfile[var][t], ncfile['elevation'][t], plotOutFname, + variableName=var) + + flist = glob.glob(os.path.join(wrr.plottingDirectory, f"CMTB_*{var}*.png")) + sb.makegif(flist, ofname=os.path.join(wrr.plottingDirectory, f"CMTB_{wrr.modelName}_{var}.gif")) + sb.myTarMaker(os.path.join(wrr.plottingDirectory, f'CMTB_{wrr.modelName}_{var}.tar.gz'), + fileList=flist) + else: raise NotImplementedError("other model plotting types haven't been implemented yet") # __________________________2b. point output _________________________________ @@ -273,10 +290,7 @@ class objects as listed below: # __________________________2bb. point plotting ________________________________ print("is this necessary??") - - - - + def cshoreSimSetup(startTimeString, inputDict, allWave, allBathy, allWL, allWind, allCTD, wrr): """Author: David Young @@ -305,34 +319,23 @@ def cshoreSimSetup(startTimeString, inputDict, allWave, allBathy, allWL, allWind # begin by setting up input parameters simulationDuration = int(inputDict.get('simulationDuration', 24)) timeStep = (inputDict.get('timeStep',3600)) - plotFlag = inputDict.get('plotFlag', True) print('TODO: rename these unpacked variables [frontbackNew.preprocess]') - try: - version_prefix = wrr.versionPrefix - except: - version_prefix = inputDict['modelSettings'].get('version_prefix', 'base').lower() - plotFlag = inputDict.get('plotFlag', True) pathPrefix = wrr.workingDirectory - model = wrr.modelName # inputDict['modelSettings'].get('model', 'ww3').lower() rawspec = allWave rawwind = allWind rawWL = allWL rawCTD = allCTD rawBathy = allBathy - - # ___________________define version parameters_________________________________ - full = True # __________________set times _________________________________________________ startTime = DT.datetime.strptime(startTimeString, '%Y-%m-%dT%H:%M:%SZ') endTime = startTime + DT.timedelta(0, simulationDuration * 3600, 0) - dateString = wrr.dateString # startTime.strftime('%Y-%m-%dT%H%M%SZ') ftime = simulationDuration*3600. - reltime = np.arange(0,ftime+timeStep,timeStep) + reltime = np.arange(0, ftime+timeStep, timeStep) print("Model Time Start : %s Model Time End: %s" % (startTime, endTime)) - + model = wrr.modelName # __________________Make Diretories_____________________________________________ fileHandling.makeCMTBfileStructure(pathPrefix) @@ -351,29 +354,21 @@ def cshoreSimSetup(startTimeString, inputDict, allWave, allBathy, allWL, allWind # outputPath=pathPrefix, model=model, waveTimeList=waveTimeList, ww3nFreq=nFreq) # print('TODO: @Ty add values for nFreq here! [frontBackNew.line72]') print(reltime, startTime) - wavepacket = prepdata.prep_CSHOREwaves(rawspec, reltime , startTime) + wavepacket = prepdata.prep_CSHOREwaves(rawspec, reltime , startTime, pierAng=wrr.shoreNormal) wlTimeList = [startTime + DT.timedelta(seconds=tt) for tt in reltime] - WLpacket = prepdata.prep_WL(rawWL,wlTimeList) + WLpacket = prepdata.prep_WL(rawWL, wlTimeList) windTimeList= [startTime + DT.timedelta(seconds=tt) for tt in reltime] - windpacket = prepdata.prep_wind(rawwind, windTimeList, model=model) # vector average, rotate winds, correct to 10m + + # vector average, rotate winds, correct to 10m + windpacket = prepdata.prep_wind(rawwind, windTimeList, model=model, shoreNormal=wrr.shoreNormal) # pull the stuff I need out of the dict timerun = inputDict['simulationDuration'] version_prefix = inputDict['modelSettings']['version_prefix'] profile_num = inputDict['profileNumber'] bathy_loc = inputDict['bathyLoc'] - workingDir = inputDict['workingDirectory'] - if 'THREDDS' in inputDict: - server = inputDict['THREDDS'] - else: - print('Chosing CHL thredds by Default, this may be slower!') - server = 'CHL' - # ____________________GENERAL ASSUMPTION VARIABLES__________ - - model = 'CSHORE' - path_prefix = os.path.join(workingDir, model, '%s/' % version_prefix) - time_step = 1 # time step for model in hours + dx = 1 # cross-shore grid spacing (FRF coord units - m) fric_fac = 0.015 # default friction factor @@ -382,33 +377,12 @@ def cshoreSimSetup(startTimeString, inputDict, allWave, allBathy, allWL, allWind # Time Stuff! if type(timerun) == str: timerun = int(timerun) - #start_time = DT.datetime.strptime(startTime, '%Y-%m-%dT%H:%M:%SZ') start_time = startTime - bathy_loc_List = np.array(['integrated_bathy', 'survey']) - assert start_time.minute == 0 and start_time.second == 0 and start_time.microsecond == 0, 'Your simulation must start on the hour!' - end_time = start_time + DT.timedelta(days=0, hours=timerun) # removed for ilab=1 , minutes=1) - print(end_time) - date_str = start_time.strftime('%Y-%m-%dT%H%M%SZ') - # start making my metadata dict - #meta_dict = {'startTime': DT.datetime.strftime(startTime,'%Y-%m-%dT%H:%M:%SZ'), - # 'timerun': timerun, - # 'time_step': time_step, - # 'dx': dx, - # 'fric_fac': fric_fac, - # 'version': version_prefix} - #ftime = timerun * 3600 # [sec] final time, dictates model duration - #dt = time_step * 3600 # time interval (sec) for wave and water level conditions - #BC_dict = {'timebc_wave': np.arange(0, ftime + dt, dt)} - - bathypacket = prepdata.prep_CSHOREbathy(rawBathy, bathy_loc, dx, wavepacket, profile_num=profile_num,fric_fac=fric_fac) - # ______________________________________________________________________________ - # __________________Make Diretories_____________________________________________ - #if not os.path.exists(path_prefix + date_str): # if it doesn't exist - # os.makedirs(path_prefix + date_str) # make the directory - #if not os.path.exists(path_prefix + date_str + "/figures/"): - # os.makedirs(path_prefix + date_str + "/figures/") + + bathypacket = prepdata.prep_CSHOREbathy(rawBathy, bathy_loc, dx, wavepacket, profile_num=profile_num, + fric_fac=fric_fac) print("Model Time Start : %s Model Time End: %s" % (start_time, end_time)) #print("Files will be placed in {0} folder".format(path_prefix + date_str)) diff --git a/genericWorkFlow.py b/genericWorkFlow.py index f7052c5..6e24f14 100755 --- a/genericWorkFlow.py +++ b/genericWorkFlow.py @@ -31,6 +31,8 @@ def Master_workFlow(inputDict): pbsFlag = inputDict['pbsFlag'] analyzeFlag = inputDict['analyzeFlag'] plotFlag = inputDict['plotFlag'] + hotStartFlag = inputDict['hotStartFlag'] + hotStartDirectory = inputDict.get('hotStartDirectory',None) modelName = inputDict['modelSettings'].get('modelName', None) log = inputDict.get('logging', True) updateBathy = inputDict.get('updateBathy', None) @@ -94,9 +96,8 @@ def Master_workFlow(inputDict): if modelName in ['ww3']: wrr = wrrClass.ww3io(workingDirectory=workingDirectory,testName=testName, versionPrefix=version_prefix, startTime=DT.datetime.strptime(time, '%Y-%m-%dT%H:%M:%SZ'), - endTime=DT.datetime.strptime(time, '%Y-%m-%dT%H:%M:%SZ') + DT.timedelta( - hours=inputDict['simulationDuration']), runFlag=runFlag, - generateFlag=generateFlag, readFlag=analyzeFlag, pbsFlag=pbsFlag) + endTime=DT.datetime.strptime(endTime, '%Y-%m-%dT%H:%M:%SZ'), runFlag=runFlag, + generateFlag=generateFlag, readFlag=analyzeFlag, pbsFlag=pbsFlag, hotStartFlag=hotStartFlag) if generateFlag is True: wavePacket, windPacket, wlPacket, bathyPacket, gridFname, wrr = frontBackNEW.ww3simSetup(time, @@ -126,12 +127,13 @@ def Master_workFlow(inputDict): wrr = pickle.load(open(os.path.join(workingDirectory,f"{dateString}_io.pickle"), 'rb'), protocol=pickle.HIGHEST_PROTOCOL) elif modelName in ['cshore']: - wrr = wrrClass.cshoreio(workingDirectory=workingDirectory,testName=testName, versionPrefix=version_prefix, + wrr = wrrClass.cshoreio(workingDirectory=workingDirectory, testName=testName, versionPrefix=version_prefix, startTime=DT.datetime.strptime(time, '%Y-%m-%dT%H:%M:%SZ'), simulatedRunTime=inputDict['simulationDuration'], endTime=DT.datetime.strptime(time, '%Y-%m-%dT%H:%M:%SZ') + DT.timedelta( hours=inputDict['simulationDuration']), runFlag=runFlag, - generateFlag=generateFlag, readFlag=analyzeFlag, pbsFlag=pbsFlag) + generateFlag=generateFlag, readFlag=analyzeFlag, pbsFlag=pbsFlag, shoreNormal=72, + xOrigin=rawspec['xFRF']) if generateFlag is True: rawbathy = go.getBathyTransectFromNC(profilenumbers=960) rawctd = go.getCTD() @@ -156,18 +158,18 @@ def Master_workFlow(inputDict): print("windPacket has keys: {}".format(windPacket.keys())) except AttributeError: pass - - if pbsFlag is True: - wrr.hpcCores = inputDict['hpcSettings']['hpcCores'] - wrr.hpcNodes = inputDict['hpcSettings']['hpcNodes'] + print(updateBathy) # write simulation files (if assigned) wrr.writeAllFiles(wavePacket=wavePacket, windPacket=windPacket, wlPacket=wlPacket, bathyPacket=bathyPacket, gridfname=gridFname, - ctdPacket=ctdPacket, updateBathy=updateBathy) + ctdPacket=ctdPacket, updateBathy=updateBathy,hotStartDirectory=hotStartDirectory) # run simulation (as appropriate) if runFlag is True: - wrr.runSimulation(modelExecutable=inputDict['modelExecutable']) + if pbsFlag is True: + wrr.hpcCores = inputDict['hpcSettings']['hpcCores'] + wrr.hpcNodes = inputDict['hpcSettings']['hpcNodes'] + wrr.runSimulation(modelExecutable=inputDict['modelExecutable'], hotStartDirectory=hotStartDirectory) # post process (as appropriate) if analyzeFlag == True: @@ -183,7 +185,8 @@ def Master_workFlow(inputDict): if inputDict['slack'] is not None: myslack = cmtbSlack.slack('testbedutils/slackSettings.yml') # initialize - myslack.postMessageWithFiles(f"checkout {wrr.modelName} simulations from {wrr.dateString}", + myslack.postMessageWithFiles(f"Dear Sir/Madam, please look at the plots generated by the " + f"model {wrr.modelName} during the time of {wrr.dateString}", moveFnames) else: @@ -202,7 +205,6 @@ def Master_workFlow(inputDict): logging.exception('\nERROR FOUND @ {}\n'.format(time, exc_info=True)) os.chdir(cmtbRootDir) - if __name__ == "__main__": opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) print('___________________________________\n___________________________________\n___________________' diff --git a/getdatatestbed b/getdatatestbed index 751b245..0b8cbdc 160000 --- a/getdatatestbed +++ b/getdatatestbed @@ -1 +1 @@ -Subproject commit 751b2451e91eb109759553d28c8a7639c5cd95c1 +Subproject commit 0b8cbdc91b08b35f4efcf738e7cdcfa94c166701 diff --git a/notebooks/cshore/cshore_example.ipynb b/notebooks/cshore/cshore_example.ipynb index bfd4899..1d3d9a4 100644 --- a/notebooks/cshore/cshore_example.ipynb +++ b/notebooks/cshore/cshore_example.ipynb @@ -13,6 +13,8 @@ "from prepdata import inputOutput\n", "from prepdata import writeRunRead as wrr\n", "from testbedutils import fileHandling\n", + "from prepdata import py2netCDF as p2nc\n", + "\n", "\n", "import datetime\n", "import matplotlib.pyplot as plt\n", @@ -22,6 +24,7 @@ "import plotly\n", "import pickle\n", "import yaml\n", + "\n", "%matplotlib inline" ] }, @@ -55,20 +58,7 @@ "metadata": {}, "outputs": [], "source": [ - "#rawWL = go.getWL()\n", - "#rawwave_data8m = go.getWaveSpec('8m-array')\n", - "rawwave_data6m = go.getWaveData('awac-6m',spec=True)\n", - "#rawwind = go.getWind()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#cmtb_data = getDataFRF.getDataTestBed(d1, d1+datetime.timedelta(minutes=1))\n", - "#bathy_data = cmtb_data.getBathyIntegratedTransect()" + "rawwave_data6m = go.getWaveData('awac-6m',spec=True)" ] }, { @@ -99,15 +89,6 @@ "waves = prepdata.prep_CSHOREwaves(rawwave_data6m, reltime , d1)" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#Bathy stuff is really slow right now. look into it" - ] - }, { "cell_type": "code", "execution_count": null, @@ -120,16 +101,6 @@ "fric_fac = 0.015" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#prof_nums = go.getBathyTransectProfNum()\n", - "#print(prof_nums)" - ] - }, { "cell_type": "code", "execution_count": null, @@ -155,7 +126,7 @@ "metadata": {}, "outputs": [], "source": [ - "b_dict = prepdata.prep_CSHOREbathy(bathy_data, bathy_loc, profile_num, dx, waves, fric_fac)\n", + "b_dict = prepdata.prep_CSHOREbathy(bathy_data, bathy_loc, dx, waves, fric_fac=fric_fac, profile_num=profile_num)\n", "print(bathy_data)\n", "print(b_dict)" ] @@ -201,7 +172,17 @@ "metadata": {}, "outputs": [], "source": [ - "wl_data" + "rawWind = go.getWind()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "windTimeList = [d1 + datetime.timedelta(seconds=tt) for tt in reltime]\n", + "wind_data = prepdata.prep_wind(rawWind,windTimeList)" ] }, { @@ -217,7 +198,7 @@ "metadata": {}, "outputs": [], "source": [ - "cshoreio = wrr.cshoreio(pathPrefix='/Users/rdchlth9/Codes/cmtb_refactor/notetbooks/cshore/data', fNameBase=fname+'_cmtb', versionPrefix='base',\n", + "cshoreio = wrr.cshoreio(workingDirectory='/Users/rdchlth9/Codes/cmtb_refactor/notetbooks/cshore/data', testName=fname+'_cmtb', versionPrefix='base',\n", " startTime=d1, endTime=d2, runFlag=True,\n", " generateFlag=True, readFlag=False)" ] @@ -357,7 +338,7 @@ "metadata": {}, "outputs": [], "source": [ - "cshoreiofull = wrr.cshoreio(pathPrefix='/Users/rdchlth9/Codes/cmtb_refactor/notetbooks/cshore/data', fNameBase=fname+'_cmtb_full', versionPrefix='base',\n", + "cshoreiofull = wrr.cshoreio(workingDirectory='/Users/rdchlth9/Codes/cmtb_refactor/notetbooks/cshore/data', testName=fname+'_cmtb_full', versionPrefix='base',\n", " startTime=d1, endTime=d2, timeStep=dt, runFlag=True,\n", " generateFlag=True, readFlag=False)" ] @@ -413,7 +394,7 @@ "metadata": {}, "outputs": [], "source": [ - "resultsfull = cshoreiofull.readAllFiles()" + "spatialData, pointData = cshoreiofull.readAllFiles()" ] }, { @@ -422,16 +403,9 @@ "metadata": {}, "outputs": [], "source": [ - "resultsfull['params']" + "spatialData['params']" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, { "cell_type": "code", "execution_count": null, @@ -450,8 +424,8 @@ "yy['simulationDuration'] = simduration\n", "yy['modelExecutable'] = '/Users/rdchlth9/Public/cshore/src-repo/cshore.exe'\n", "yy['workingDirectory'] = '/data'\n", - "yy['netCDFdir'] = '/thredds_data'\n", - "yy['logfileLoc'] = '/cmtb_refactor/data'\n", + "yy['netCDFdir'] = '/Users/rdchlth9/Codes/cmtb_refactor/thredds_data'\n", + "yy['logfileLoc'] = '/Users/rdchlth9/Codes/cmtb_refactor/data'\n", "yy['plotFlag'] = False\n", "yy['generateFlag'] = True\n", "yy['runFlag'] = True\n", @@ -474,7 +448,7 @@ "metadata": {}, "outputs": [], "source": [ - "%run ../../genericWorkFlow.py test.yaml" + "#%run ../../genericWorkFlow.py test.yaml" ] }, { diff --git a/plotting/operationalPlots.py b/plotting/operationalPlots.py index a001b53..b6d1c71 100644 --- a/plotting/operationalPlots.py +++ b/plotting/operationalPlots.py @@ -493,7 +493,7 @@ def plotSpatialFieldData(contourpacket, fieldpacket, prefix='', nested=True, **k plt.savefig(prefix + namebase + '_%s.png' % time[tt][0].strftime("%Y%m%d%H%M")) plt.close() -def plotWaveProfile(x, waveHs, bathyToPlot, fname): +def plotWaveProfile(x, waveHs, bathyToPlot, fname, **kwargs): """This function will plot the Cross shore Wave profile at the FRF Xshore array Args: @@ -509,26 +509,25 @@ def plotWaveProfile(x, waveHs, bathyToPlot, fname): a saved plot """ - profileToPlot = waveHs - # if bathyField.ndim == 3: - # bathyToPlot = -bathyField[0, yLocation, :] - # elif bathyField.ndim == 2: - # bathyToPlot = -bathyField[yLocation, :] - # if profileToPlot.shape[0] == 200: - # dx = 5 - # elif profileToPlot.shape[0] == 100: - # dx = 10 - ## setup - + profileToPlot = kwargs.get('variableName', waveHs) + # figure - fig, ax1 = plt.subplots(figsize=(8,4)) - ax1.plot(x, profileToPlot, 'b', lw=3) - ax1.set_ylabel('Wave Height [m]', color='b') - ax2 = ax1.twinx() - ax2.plot(x, bathyToPlot, 'brown', lw=2) - ax2.set_ylabel('Bathymetry Depth[m] NAVD88', color='brown') - plt.xlabel('STWAVE Cross Shore Position [m]') - plt.title('Wave Height at the FRF Cross Shore Array') + fig = plt.figure(figsize=(8,4)) + ax1 = plt.subplot2grid((3,4),(0,0), colspan=4, rowspan=2) + ax1.fill_between(x, waveHs, 0, color='b', alpha=.5, lw=3) + ax1.set_ylabel(f'{profileToPlot}', color='b') + if profileToPlot != 'waveHs': + ax1.set_ylim([-1,1]) + else: + ax1.set_ylim([0,4]) + ax2 = plt.subplot2grid((3,4),(2,0), colspan=4, rowspan=1, sharex=ax1) + ax2.fill_between(x, bathyToPlot, bathyToPlot.min(), color='khaki', lw=2) + + ax2.set_ylabel('Bathymetry [m]') + ax2.set_xlabel('Cross Shore Position [m]') + plt.subplots_adjust(hspace=0) + plt.suptitle(f'Cross-shore evolution of {profileToPlot}') + plt.savefig(fname) plt.close() diff --git a/prepdata b/prepdata index fd544cd..aba8c60 160000 --- a/prepdata +++ b/prepdata @@ -1 +1 @@ -Subproject commit fd544cd549f2d39ef04e7a6d7900fe09db6ce8c8 +Subproject commit aba8c609f1d39764e7185720c4160ff2a3dcaaed diff --git a/testbedutils b/testbedutils index b12bbba..2f2f512 160000 --- a/testbedutils +++ b/testbedutils @@ -1 +1 @@ -Subproject commit b12bbba4803d0a9cb3935c7f138ed3226c3390d7 +Subproject commit 2f2f512475734245fef6c1a2cbb053b288559a56 diff --git a/yaml_files/TestBedExampleInputs/CSHORE_Input_example_v2.yml b/yaml_files/TestBedExampleInputs/CSHORE_Input_example_v2.yml new file mode 100644 index 0000000..22c0237 --- /dev/null +++ b/yaml_files/TestBedExampleInputs/CSHORE_Input_example_v2.yml @@ -0,0 +1,17 @@ +THREDDS: CHL +analyzeFlag: true +bathyLoc: survey +endTime: '2018-03-06T00:00:00Z' +generateFlag: true +logfileLoc: ./cmtb_refactor/data +modelExecutable: /Users/rdchlth9/Public/cshore/src-repo/cshore.exe +modelSettings: + modelName: cshore + version_prefix: FIXED +netCDFdir: ./thredds_data +plotFlag: false +profileNumber: 960 +runFlag: true +simulationDuration: 24.0 +startTime: '2018-03-05T00:00:00Z' +workingDirectory: ./data diff --git a/yaml_files/TestBedExampleInputs/ww3_Input_example.yml b/yaml_files/TestBedExampleInputs/ww3_Input_example.yml index c1a8ec7..b0c31d9 100644 --- a/yaml_files/TestBedExampleInputs/ww3_Input_example.yml +++ b/yaml_files/TestBedExampleInputs/ww3_Input_example.yml @@ -16,7 +16,7 @@ modelExecutable: /modelSourceCodes/WW3/model/exe # path to all appropriate exe logging: False # optional verbose: True # optional modelSettings: - model: ww3 # model name string, used for filename/path generation + modelName: ww3 # model name string, used for filename/path generation version_prefix: base # controls switched within the code grid: grids/ww3/Mesh_interp_Mar2018.msh # base grid sim REQUIRED diff --git a/yaml_files/TestBedExampleInputs/ww3_Input_example_v2.yml b/yaml_files/TestBedExampleInputs/ww3_Input_example_v2.yml new file mode 100644 index 0000000..22c0237 --- /dev/null +++ b/yaml_files/TestBedExampleInputs/ww3_Input_example_v2.yml @@ -0,0 +1,17 @@ +THREDDS: CHL +analyzeFlag: true +bathyLoc: survey +endTime: '2018-03-06T00:00:00Z' +generateFlag: true +logfileLoc: ./cmtb_refactor/data +modelExecutable: /Users/rdchlth9/Public/cshore/src-repo/cshore.exe +modelSettings: + modelName: cshore + version_prefix: FIXED +netCDFdir: ./thredds_data +plotFlag: false +profileNumber: 960 +runFlag: true +simulationDuration: 24.0 +startTime: '2018-03-05T00:00:00Z' +workingDirectory: ./data diff --git a/yaml_files/waveModels/cshore/cshore_var.yml b/yaml_files/waveModels/cshore/cshore_var.yml new file mode 100644 index 0000000..da1a045 --- /dev/null +++ b/yaml_files/waveModels/cshore/cshore_var.yml @@ -0,0 +1,311 @@ +# CSHORE template + +_variables: ['time', 'xFRF', 'aveE', 'aveN', 'waveHs', 'waveMeanDirection', 'waterLevel', 'setup', 'totalWaterLevel', 'runupMean', 'elevation', 'latitude', 'longitude', 'profileNumber', 'bathymetryDate', 'yFRF', 'waveFlag'] +_attributes: ['notes'] +_dimensions: ['time', 'xFRF'] + + +time: + name: 'time' + units: 'seconds since 1970-01-01 00:00:00' + standard_name: '' + long_name: 'UTC Model Time' + data_type: 'f8' + dim: ['time'] + calendar: 'gregorian' + fill_value: '-999.99' + +xFRF: + name: 'xFRF' + units: 'm' + standard_name: '' + long_name: 'Cross-shore position in m' + data_type: 'f8' + dim: ['xFRF'] + fill_value: '-999.99' + short_name: 'xFRF' + coordinates: 'xFRF yFRF' + description: 'Cross-shore position of the CMTB CSHORE model nodes in FRF coordinates (xFRF)' + + +# hydro stuff +aveE: + name: 'aveE' + units: 'm/s' + standard_name: '' + long_name: 'Depth averaged eastward current' + data_type: 'f8' + dim: ['time', 'xFRF'] + fill_value: '-999.99' + short_name: 'Mean Eastward Current' + coordinates: 'xFRF yFRF' + description: 'Depth averaged eastward current at each node along the Modeled Transect from CMTB CSHORE model run' + +stdE: + name: 'stdE' + units: 'm/s' + standard_name: '' + long_name: 'Standard deviation of the depth averaged eastward current' + data_type: 'f8' + dim: ['time', 'xFRF'] + fill_value: '-999.99' + short_name: 'Standard Deviation of Eastward Current' + coordinates: 'xFRF yFRF' + description: 'Standard deviation of the depth averaged eastward current at each node along the Modeled Transect from CMTB CSHORE model run' + +aveN: + name: 'aveN' + units: 'm/s' + standard_name: '' + long_name: 'Depth averaged northward current' + data_type: 'f8' + dim: ['time', 'xFRF'] + fill_value: '-999.99' + short_name: 'Mean Northward Current' + coordinates: 'xFRF yFRF' + description: 'Depth averaged northward current at each node along the Modeled Transect from CMTB CSHORE model run' + +stdN: + name: 'stdN' + units: 'm/s' + standard_name: '' + long_name: 'Standard deviation of the depth averaged northward current' + data_type: 'f8' + dim: ['time', 'xFRF'] + fill_value: '-999.99' + short_name: 'Standard Deviation of Northward Current' + coordinates: 'xFRF yFRF' + description: 'Standard deviation of the depth averaged northward current at each node along the Modeled Transect from CMTB CSHORE model run' + +waveHs: + name: 'waveHs' + units: 'm' + standard_name: '' + long_name: 'Significant Wave Height' + data_type: 'f8' + dim: ['time', 'xFRF'] + fill_value: '-999.99' + short_name: 'Wave Height' + coordinates: 'xFRF yFRF' + description: 'Significant Wave Height across the Modeled Transect from CMTB CSHORE model run' + +waveMeanDirection: + name: 'waveMeanDirection' + units: 'Degrees' + standard_name: '' + long_name: 'Mean Wave Direction measured from true north' + data_type: 'f8' + dim: ['time', 'xFRF'] + fill_value: '-999.99' + short_name: 'Mean Direction' + coordinates: 'xFRF yFRF' + description: 'Mean wave Direction along the Modeled Transect from CMTB CSHORE model run' + +waterLevel: + name: 'waterLevel' + units: 'm' + standard_name: '' + long_name: 'mean water surface elevation' + data_type: 'f8' + dim: ['time'] + fill_value: '-999.99' + short_name: 'mwl' + coordinates: 'xFRF yFRF' + description: 'Mean water surface elevation along the Modeled Transect from CSHORE model run' + +setup: + name: 'setup' + units: 'm' + standard_name: '' + long_name: 'wave setup/setdown' + data_type: 'f8' + dim: ['time', 'xFRF'] + fill_value: '-999.99' + short_name: 'setup' + coordinates: 'xFRF yFRF' + description: 'Wave setup/setdown along the modeled transect from CSHORE model run' + +totalWaterLevel: + name: 'totalWaterLevel' + units: 'm' + standard_name: '' + long_name: '2 percent exceedence runup elevation' + data_type: 'f8' + dim: ['time'] + fill_value: '-999.99' + short_name: 'R2%' + coordinates: '' + description: '2 percent exceedence runup elevation from the CSHORE mode' + +#sediment stuff +qbx: + name: 'qbx' + units: 'm2/s' + standard_name: '' + long_name: 'cross-shore bedload sediment transport rate' + data_type: 'f8' + dim: ['time', 'xFRF'] + fill_value: '-999.99' + short_name: 'qbx' + coordinates: 'xFRF yFRF' + description: 'Cross-shore bedload sediment transport rate along the Modeled Transect from CMTB CSHORE model run' + +qsx: + name: 'qsx' + units: 'm2/s' + standard_name: '' + long_name: 'cross-shore suspended sediment transport rate' + data_type: 'f8' + dim: ['time', 'xFRF'] + fill_value: '-999.99' + short_name: 'qsx' + coordinates: 'xFRF yFRF' + description: 'Cross-shore suspended sediment transport rate along the Modeled Transect from CMTB CSHORE model run' + +qby: + name: 'qby' + units: 'm2/s' + standard_name: '' + long_name: 'along-shore bedload sediment transport rate' + data_type: 'f8' + dim: ['time', 'xFRF'] + fill_value: '-999.99' + short_name: 'qby' + coordinates: 'xFRF yFRF' + description: 'Along-shore bedload sediment transport rate along the Modeled Transect from CMTB CSHORE model run' + +qsy: + name: 'qsy' + units: 'm2/s' + standard_name: '' + long_name: 'along-shore suspended sediment transport rate' + data_type: 'f8' + dim: ['time', 'xFRF'] + fill_value: '-999.99' + short_name: 'qsy' + coordinates: 'xFRF yFRF' + description: 'Along-shore suspended sediment transport rate along the Modeled Transect from CMTB CSHORE model run' + +probabilitySuspension: + name: 'probabilitySuspension' + units: '' + standard_name: '' + long_name: 'probability of sediment suspension (0-1)' + data_type: 'f8' + dim: ['time', 'xFRF'] + fill_value: '-999.99' + short_name: 'ps' + coordinates: 'xFRF yFRF' + description: 'Probability of sediment suspension (0-1) along the Modeled Transect from CMTB CSHORE model run' + +probabilityMovement: + name: 'probabilityMovement' + units: '' + standard_name: '' + long_name: 'probability of sediment movement (0-1)' + data_type: 'f8' + dim: ['time', 'xFRF'] + fill_value: '-999.99' + short_name: 'pb' + coordinates: 'xFRF yFRF' + description: 'Probability of sediment movement (0-1) along the Modeled Transect from CMTB CSHORE model run' + +suspendedSedVolume: + name: 'suspendedSedVolume' + units: 'm3/m2' + standard_name: '' + long_name: 'suspended sediment volume per unit horizontal bottom area' + data_type: 'f8' + dim: ['time', 'xFRF'] + fill_value: '-999.99' + short_name: 'vs' + coordinates: 'xFRF yFRF' + description: 'Suspended sedimet volume per unti horizontal bottom area along the Modeled Transect from CMTB CSHORE model run' + + +# morpho stuff +elevation: + name: 'elevation' + units: 'm' + standard_name: '' + long_name: 'bathymetry elevation' + data_type: 'f8' + dim: ['time', 'xFRF'] + fill_value: '-999.99' + short_name: 'bathy' + coordinates: 'xFRF yFRF' + description: 'Bottom elevation for the CSHORE model bathymetry in NAVD88' + + +# extra stuff +latitude: + name: 'latitude' + units: 'Degrees' + standard_name: '' + long_name: 'Latitude of each node in decimal degrees' + data_type: 'f8' + dim: ['xFRF'] + fill_value: '-999.99' + short_name: 'lat' + coordinates: 'xFRF yFRF' + description: 'Latitude of the CMTB CSHORE model nodes in decimal degrees' + +longitude: + name: 'longitude' + units: 'Degrees' + standard_name: '' + long_name: 'Longitude of each node in decimal degrees' + data_type: 'f8' + dim: ['xFRF'] + fill_value: '-999.99' + short_name: 'lon' + coordinates: 'xFRF yFRF' + description: 'Longitude of the CMTB CSHORE model nodes in decimal degrees' + +profileNumber: + name: 'profileNumber' + units: '' + standard_name: '' + long_name: 'The profile number of the initial bathymetry' + data_type: 'f8' + dim: ['time'] + fill_value: '-999.99' + short_name: 'profileNum' + coordinates: '' + description: 'The profile number of the bathymetric survey used to initialize the model' + +bathymetryDate: + name: 'bathymetryDate' + units: 'seconds since 1970-01-01 00:00:00' + standard_name: '' + long_name: 'The date the survey bathymetry used to inialize the model was taken' + data_type: 'f8' + dim: ['time'] + fill_value: '-999.99' + short_name: 'bathyDate' + coordinates: '' + description: 'This marks when the bathymetry was measured if done by a traditional survey technique' + +yFRF: + name: 'yFRF' + units: 'm' + standard_name: '' + long_name: 'The yFRF position of the transect' + data_type: 'f8' + dim: ['time'] + fill_value: '-999.99' + short_name: 'yFRF' + coordinates: 'xFRF yFRF' + description: 'The yFRF position of the BC used in the model (and therefore the entire transect)' + +waveFlag: + name: 'waveFlag' + units: '' + standard_name: '' + long_name: 'Wave quality control flag value' + data_type: 'u2' + dim: ['time'] + fill_value: '-999' + short_name: 'waveFlag' + coordinates: '' + description: 'These flags are markers for the quality of wave input data into the model. There are 2 main flags in place currently:\n 0: Good Data\n1:Linearly Interpolated Data - these data are interpolated due to missing or poorly flagged input data' diff --git a/yaml_files/CSHORE/CSHORE_fixed_global.yml b/yaml_files/waveModels/cshore/fixed/cshore_global.yml similarity index 73% rename from yaml_files/CSHORE/CSHORE_fixed_global.yml rename to yaml_files/waveModels/cshore/fixed/cshore_global.yml index 647ac55..a08397e 100644 --- a/yaml_files/CSHORE/CSHORE_fixed_global.yml +++ b/yaml_files/waveModels/cshore/fixed/cshore_global.yml @@ -2,8 +2,10 @@ featureType: grid title: Fixed CSHORE Results summary: > USACE CSHORE model data generated as part of the Coastal Model Test Bed(CMTB). - This component of the SMTB is composed of CSHORE model runs with a fixed bed for all time steps - I'm not sure what else needs to go here...: + The model data are generated with a fixed (non-evolving) bathymetry boundary condition. + For more information about the CSHORE model, please refer to Kobayashi et al. 2009 and Johnson, + Bradley D., Nobuhisa Kobayashi, and Mark B. Gravens. "Cross-shore numerical model CSHORE for waves, + currents, sediment transport and beach profile evolution." (2012). history: data set created as part of the Coastal Model Test Bed(CMTB), CSHORE model data generated at the FRF source: CMTB CSHORE simulations platform: FRF Cluster - Crunchy @@ -16,8 +18,8 @@ creator_name: USACE/CHL/COAB creator_url: http://frf.usace.army.mil creator_email: frfwebmaster@usace.army.mil license: These data may be redistributed and used without restriction. Data are intended for scholarly use by the research community, with the express agreement that users will properly acknowledge the USACE Field Research Facility and the supporting investigator(s). Use or reproduction of these data for commercial purposes is prohibited without prior written permission. -keywords_vocabulary: FGlobal Change Master Directory (GCMD) Earth Science Keywords; CF Standard Name Table (v23, 23 March 2013) -keywords: Oceans > Ocean Waves > Wave Frequency, Oceans > Ocean Waves > Wave Height, Oceans > Ocean Waves > Wave Period, Oceans > Ocean Waves > Wave Spectra, Oceans > Ocean Waves > Wave Direction, DOD > DOD/USARMY/USACE/CHL/FRF > Field Research Facility, Coastal And Hydraulics Laboratory,U. S. Army Corps Of Engineers, U.S. Army, U. S. Department Of Defense, sea_surface_wave_variance_spectral_density, sea_surface_wave_significant_height, sea_surface_wave_from_direction, sea_surface_wave_directional_variance_spectral_density +keywords_vocabulary: Global Change Master Directory (GCMD) Earth Science Keywords; CF Standard Name Table (v23, 23 March 2013) +keywords: DOD > DOD/USARMY/USACE/CHL/FRF > Field Research Facility, Coastal And Hydraulics Laboratory,U. S. Army Corps Of Engineers, U.S. Army, U. S. Department Of Defense, sea_surface_wave_variance_spectral_density, sea_surface_wave_significant_height, sea_surface_wave_from_direction, sea_surface_wave_directional_variance_spectral_density processing: realtime organization: USACE/CHL/COAB publisher_url: http://frf.usace.army.mil diff --git a/yaml_files/ww3_TimeIntrpolatantBug.yml b/yaml_files/ww3_TimeIntrpolatantBug.yml deleted file mode 100644 index 232cdc2..0000000 --- a/yaml_files/ww3_TimeIntrpolatantBug.yml +++ /dev/null @@ -1,25 +0,0 @@ -# # # # # # # # # # # # -# Data control # -# # # # # # # # # # # # -plotFlag: True # turn plotting on -generateFlag: True # generate simulation input files (go get data, process, and write files) -runFlag: True # run the simulation -analyzeFlag: True # post process simulations (read files, post proces -bathyLoc: integrated_bathy # bathymetry source. OPTIONAL: defaults to integrated_bathy -######################## -#simulations parameters# -######################## -startTime: 2020-10-04T00:00:00Z # project start time -endTime: 2020-10-05T00:00:00Z # project End time -simulationDuration: 24 # duration in hours - how frequently to get new data, size of individual simulations -modelExecutable: /modelSourceCodes/WW3/model/exe # path to all appropriate executables (grid, bounc, shel) -logging: False # optional -verbose: True # optional -modelSettings: - modelName: ww3 # model name string, used for filename/path generation - version_prefix: base # controls switched within the code - grid: grids/ww3/Mesh_interp_Mar2018.msh # base grid sim REQUIRED - -waveSettings: - waveFlag: True -