"""Get your rasters into arrays""" water_raster_wildcard = "/run/media/dav/SHETLAND/ModelRuns/Ryedale_storms/Gridded/Hydro/WaterDepths*.asc" water_raster_file = "/mnt/SCRATCH/Analyses/HydrogeomorphPaper/peak_flood_maps/ryedale/WaterDepths2880_GRID_TLIM.asc" #raster_file = "/run/media/dav/SHETLAND/Analyses/HydrogeomorphPaper/peak_flood_maps/boscastle/peak_flood/WaterDepths2400_GRID_HYDRO.asc" floodplain_file = "/mnt/SCRATCH/Analyses/ChannelMaskAnalysis/floodplain_ryedale/RyedaleElevations_FP.bil" stream_raster_file = "/mnt/SCRATCH/Analyses/ChannelMaskAnalysis/floodplain_ryedale/RyedaleElevations_SO.bil" water_raster = lsdgdal.ReadRasterArrayBlocks(water_raster_file) floodplain_mask = lsdgdal.ReadRasterArrayBlocks(floodplain_file) stream_mask = lsdgdal.ReadRasterArrayBlocks(stream_raster_file) #print(stream_mask) DX = lsdgdal.GetUTMMaxMin(water_raster_file)[ 0] # I never realised you could do this! print(DX) """Calculate the depths and areas""" #calculate_mean_waterdepth(water_raster) #calcualte_max_waterdepth(water_raster) #calculate_waterinundation_area(water_raster, DX, 0.02) #floodplain_mean_depth(water_raster, floodplain_mask) #main_channel_mean_depth(water_raster, floodplain_mask, stream_mask) """Make the timeseries file""" simulation_inundation_timeseries( water_raster_wildcard, floodplain_mask, stream_mask, savefilename="ryedale_inundation_GRIDDED_HYDRO.txt")
def GetTicksForUTM(FileName, x_max, x_min, y_max, y_min, n_target_tics): CellSize, XMin, XMax, YMin, YMax = LSDMap_IO.GetUTMMaxMin(FileName) NDV, xsize, ysize, GeoT, Projection, DataType = LSDMap_IO.GetGeoInfo( FileName) xmax_UTM = XMax xmin_UTM = XMin ymax_UTM = YMax ymin_UTM = YMin #print "now UTM, xmax: " +str(xmax_UTM)+" x_min: " +str(xmin_UTM)+" y_maxb: " +str(ymax_UTM)+" y_minb: " +str(ymin_UTM) dy_fig = ymax_UTM - ymin_UTM dx_fig = xmax_UTM - xmin_UTM dx_spacing = dx_fig / n_target_tics dy_spacing = dy_fig / n_target_tics if (dx_spacing > dy_spacing): dy_spacing = dx_spacing str_dy = str(dy_spacing) str_dy = str_dy.split('.')[0] n_digits = str_dy.__len__() nd = int(n_digits) first_digit = float(str_dy[0]) #print "str_dy: " +str_dy+ " n_digits: " +str(nd)+" first_digit: " + str(first_digit) dy_spacing_rounded = first_digit * pow(10, (nd - 1)) #print "n_digits: "+str(n_digits)+" dy_spacing: " +str(dy_spacing) + " and rounded: "+str(dy_spacing_rounded) str_xmin = str(xmin_UTM) str_ymin = str(ymin_UTM) #print "before split str_xmin: "+ str_xmin + " str ymin: " + str_ymin str_xmin = str_xmin.split('.')[0] str_ymin = str_ymin.split('.')[0] #print "after split str_xmin: "+ str_xmin + " str ymin: " + str_ymin xmin_UTM = float(str_xmin) ymin_UTM = float(str_ymin) #print "UTM: "+ str(xmin_UTM) + " str ymin: " + str(ymin_UTM) n_digx = str_xmin.__len__() n_digy = str_ymin.__len__() #print "n_dig_x: " + str(n_digx)+ " nd: " + str(nd) if (n_digx - nd + 1) >= 1: front_x = str_xmin[:(n_digx - nd + 1)] else: front_x = str_xmin if (n_digy - nd + 1) >= 1: front_y = str_ymin[:(n_digy - nd + 1)] else: front_y = str_ymin #print "xmin: " + str_xmin + " ymin: " + str_ymin + " n_digx: " + str(n_digx)+ " n_digy: " + str(n_digy) #print "frontx: " +front_x+" and fronty: "+ front_y round_xmin = float(front_x) * pow(10, nd - 1) round_ymin = float(front_y) * pow(10, nd - 1) #print "x_min: " +str(xmin_UTM)+ " round xmin: " +str(round_xmin)+ " y_min: " +str(ymin_UTM)+" round y_min: " + str(round_ymin) # now we need to figure out where the xllocs and ylocs are xUTMlocs = np.zeros(2 * n_target_tics) yUTMlocs = np.zeros(2 * n_target_tics) xlocs = np.zeros(2 * n_target_tics) ylocs = np.zeros(2 * n_target_tics) new_x_labels = [] new_y_labels = [] round_ymax = round_ymin + dy_spacing_rounded * (2 * n_target_tics - 1) #print "n_target_tics: " + str(n_target_tics) + " round_ymax: " +str(round_ymax) for i in range(0, 2 * n_target_tics): xUTMlocs[i] = round_xmin + (i) * dy_spacing_rounded yUTMlocs[i] = round_ymin + (i) * dy_spacing_rounded #xlocs[i] = (xUTMlocs[i]-XMin) xlocs[i] = xUTMlocs[i] # need to account for the rows starting at the upper boundary ylocs[i] = round_ymax - (yUTMlocs[i] - round_ymin) #print "i: " + str(i) +" yUTM: " + str(yUTMlocs[i])+ " rounded, reversed: " +str( ylocs[i]) new_x_labels.append(str(xUTMlocs[i]).split(".")[0]) new_y_labels.append(str(yUTMlocs[i]).split(".")[0]) #print xUTMlocs #print xlocs #print yUTMlocs #print ylocs #print new_x_labels #print new_y_labels new_xlocs = [] new_xUTMlocs = [] x_labels = [] # Now loop through these to get rid of those not in range for index, xloc in enumerate(xlocs): #print xloc if (xloc < XMax and xloc > XMin): new_xlocs.append(xloc) new_xUTMlocs.append(xUTMlocs[index]) x_labels.append(new_x_labels[index]) new_ylocs = [] new_yUTMlocs = [] y_labels = [] # Now loop through these to get rid of those not in range for index, yloc in enumerate(ylocs): #print yloc if (yloc < YMax and yloc > YMin): new_ylocs.append(yloc) new_yUTMlocs.append(yUTMlocs[index]) y_labels.append(new_y_labels[index]) #print "=======================================" #print "I am getting the tick marks now" #print "X extent: " + str(XMin)+ " " +str(XMax) #print "Y extent: " + str(YMin)+ " " +str(YMax) #print "x ticks: " #print new_xlocs #print "y ticks: " #print new_ylocs #return xlocs,ylocs,new_x_labels,new_y_labels return new_xlocs, new_ylocs, x_labels, y_labels