) print(" One for the regular time series,") print( " and one for the time series that includes one reservoir's variable") print(" height from satellite altimetry data. \n") print("Only works for GRanD database reservoirs. \n") print("Usage:") print(sys.argv[0] + " ResNo\n") sys.exit() #which reservoir resNo = int(sys.argv[1]) resNoS = str(resNo) # set up db, start, end = DB('G') # directories dataDir = config.BaseDir + 'data/' figDir = config.BaseDir + 'figures/' TSDir = config.BaseDir + 'time_series/' VarDir = config.BaseDir + 'time_series/VAR/' # files we will use ResInfoFN = dataDir + 'Res.Grand.txt' OrigFPFN = TSDir + 'TS.FP.res.Grand.txt' VarFPFN = VarDir + 'TS.FP.Grand.var' + resNoS + '.txt' # output files OrigTSFN = VarDir + 'TS.point.res' + resNoS + '.Orig.txt' VarTSFN = VarDir + 'TS.point.res' + resNoS + '.VAR.txt'
print("Hist.DB.txt") print("Year\tNoOfReservoirs\tVolume\tSeepage") print("\nUsage:") print(sys.argv[0] + " DB_name\n") print( "DB_names are: \nG = GRanD\nC = under Construction\nP = Planned\nA = All" ) sys.exit() # location of database db_path = config.BaseDir + 'data/' # where you want the time series saved ts_path = config.BaseDir + 'time_series/' #get db name db, start, end = DB(sys.argv[1]) time = np.arange(start, end) ifn = db_path + "Res." + db + ".txt" ofn = ts_path + "Hist." + db + ".txt" ResList = [] InFile = open(ifn) for line in InFile: ResList.append(line.split()) InFile.close() Seep = 0 MatOut = [] for year in time: line = []
#!/usr/bin/env python3.7 import sys import os from res_subr import databases as DB from res_subr import read_res_fp as rf import numpy as np import config # the three databases cdb,a,b = DB("C") pdb,a,b = DB("P") fdb,a,b = DB("F") # the three FP directories cfpDir = config.FPDir+cdb+'/' pfpDir = config.FPDir+pdb+'/' ffpDir = config.FPDir+'/' # read the Const and Plan FPs cfp = rf(cfpDir, "All") pfp = rf(pfpDir, "All") # add them together fp = np.add(cfp,pfp) # define path ofn = ffpDir+"seagl_grid_Future.txt" # save file np.savetxt(ofn, fp, delimiter = '\t')
# This code will make a file that includes all the maximum # year-over-year increases in sea level at the points where # tide gauges are located # set up import sys import os import config from res_subr import GetIndex from res_subr import GetMaxChange from res_subr import GetMaxChangeAndTS from res_subr import databases as DB import numpy as np #We only need to do this for GRanD db, start, end = DB("G") # for each point, extract the time series and find the largest point # save the file # tide gauge data dir dataDir = config.BaseDir + "data/TideGauge/rlr_annual/" tgdir = config.BaseDir + "data/TideGauge/" tsDir = config.BaseDir + "time_series/" # file where the locations are listed tgfn = dataDir + "filelist.txt" fpfn = tsDir + "TS.FP.res.Grand.txt" #testfn = "LatLon.xy" ofn = tgdir + "TGMaxChange.txt"
Max = (math.log(float(vmax), base) + offset) / denom Min = (math.log(float(vmin), base) + offset) / denom print("max = " + str(Max)) print("min = " + str(Min)) ## First we want to make the necessary files ## # filenames DBNames = ['G', 'P', 'C'] zfn = MapsDir + "Res.Zarfl.xyzm" ZFile = open(zfn, "w") zt = 0 # flag to only write key once in ZFile for iname in DBNames: db, start, end = DB(iname) ifn = DataDir + "Res." + db + ".txt" ofn = MapsDir + "Res." + db + ".xyzm" # get res info ResList = GetData(ifn) # write to file the attributes you want OutFile = open(ofn, "w") j = 0 jstop = 10000 # write out key -- three circles denoting size of reservoirs klat = [-40, -50, -60] klon = [-140, -149, -161.5] kyr = 1 # random early year: show up saturated (black) in color scale for n in range(len(klat)):
if sys.argv[3] != 'C' and sys.argv[3] != 'Y': print(sys.argv[2] + " is invalid. Please choose C for cumulative data or") print("Y for yearly data to be displayed on the vertical axis.") sys.exit() rv = sys.argv[2] cy = sys.argv[3] factor = 1000 # location of timeseries data: ts_path = config.BaseDir + 'time_series/' # where to save the figure: fig_path = config.BaseDir + 'figures/' #get db name db, start, end = DB(sys.argv[1]) dbA, startA, endA = DB("A") # set up filenames ifn = ts_path + "Hist." + db + ".txt" ifnAll = ts_path + "Hist.All.txt" ofn = fig_path + "Hist." + db + "." + rv + "." + cy + ".pdf" # we already know the horizontal axis is time time = np.arange(start, end) timeA = np.arange(1830, endA, 10) No = [] NoA = [] Vol = [] VolA = [] Seep = []
print( "\nThis code will print a fingerprint, either for a single reservoir") print(" or for a specified time range. \n") print("Usage:") print(sys.argv[0] + " DB_name r|t [ResNo] | [YearBegin YearEnd]\n") print( "DB_names are: \nG = GRanD\nC = under Construction\nP = Planned\nF = Future (C+P)" ) print("[ResNo] = All to plot all reservoirs for a database") print( " To print all future time, include F as the first arg, na as the second" ) sys.exit() #get db name db, dbStart, dbEnd = DB(sys.argv[1]) rfpDir = config.FPDir + db + '/' tfpDir = config.BaseDir + 'time_series/' + db + '/' ofng = "gridinp.txt" DataFN = config.BaseDir + 'data/Res.' + db + '.txt' FPFigDir = config.BaseDir + 'figures/Fingerprints/' if os.path.isdir(FPFigDir) == False: os.mkdir(FPFigDir) # Decide if Reservoir or Timeseries # then get the fingerprint RT = sys.argv[2] # Reservoir if RT == 'r':