Skip to content

Commit

Permalink
update for visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
changliao1025 committed Aug 9, 2023
1 parent f271223 commit 8ec2f66
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
30 changes: 21 additions & 9 deletions pyflowline/classes/_visual_basin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def basin_plot(self,
iFlag_colorbar_in=None,
iFlag_scientific_notation_colorbar_in=None,
dData_min_in = None,
dData_max_in = None,
dData_max_in = None,
sVariable_in=None,
aExtent_in = None,
aLegend_in = None,
Expand Down Expand Up @@ -94,16 +94,22 @@ def basin_plot(self,
#should use the pyflowline simplified flowline
sFilename_dummy = self.sFilename_flowline_simplified
#now replace the folder string

sFilename1 = replace_last_occurrence(sFilename_dummy, 'hexwatershed', 'pyflowline')
sFilename_dummy = self.sFilename_flowline_conceptual
#now replace the folder string
sFilename2 = replace_last_occurrence(sFilename_dummy, 'hexwatershed', 'pyflowline')

aFiletype_in = [3, 2, 2]
aFilename_in = [sFilename_mesh, sFilename0, sFilename1]
aFiletype_in = [2, 2, 2]
aFilename_in = [sFilename0, sFilename1, sFilename2]
map_multiple_vector_data(aFiletype_in,
aFilename_in,
aFilename_in,
iFont_size_in=iFont_size_in,
sFilename_output_in=sFilename_output_in,
sTitle_in= 'Mesh with flowline and observation',
aFlag_color_in = [0, 0, 0],
#sTitle_in= 'Flow direction with observation',
aFlag_thickness_in= [1, 0, 0],
aVariable_in= ['drainage_area', '', 'segment'],
aLegend_in = aLegend_in,
aFlag_color_in = [0, 0, 1],
aFlag_fill_in = [0, 0, 0])
else:
print('Unsupported variable: ', sVariable_in, ' in basin_plot.')
Expand Down Expand Up @@ -265,6 +271,7 @@ def _plot_polygon_variable(self,
sUnit = r'Units: $m^{2}$'
dData_min = dData_min_in
dData_max = dData_max_in
sColormap ='Spectral_r'
sFilename = self.sFilename_variable_polygon
else:
if sVariable_in == 'travel_distance':
Expand All @@ -273,12 +280,13 @@ def _plot_polygon_variable(self,
sUnit = r'Unit: m'
dData_min = 0.0
dData_max = dData_max_in
sColormap ='Spectral_r'
sFilename = self.sFilename_variable_polygon
else:
sVariable='slope'
sTitle = 'Surface slope'
sUnit = 'Unit: percent'
sColormap='plasma'
sColormap='Spectral_r'
dData_min = 0.0
dData_max = dData_max_in
sFilename = self.sFilename_variable_polygon
Expand All @@ -299,6 +307,7 @@ def _plot_polygon_variable(self,
sUnit = r'Units: $m^{2}$'
dData_min = dData_min_in
dData_max = dData_max_in
sColormap ='Spectral_r'
sFilename = self.sFilename_variable_polygon

else:
Expand All @@ -308,13 +317,14 @@ def _plot_polygon_variable(self,
sUnit = r'Unit: m'
dData_min = 0.0
dData_max = dData_max_in
sColormap ='Spectral_r'
iFlag_subbasin = 1
sFilename = self.sFilename_variable_polygon
else:
sVariable='slope'
sTitle = 'Surface slope'
sUnit = r'Unit: percent'
sColormap='plasma'
sColormap='Spectral_r'
dData_min = dData_min_in
dData_max = dData_max_in
sFilename = self.sFilename_variable_polygon
Expand All @@ -334,6 +344,8 @@ def _plot_polygon_variable(self,
iFlag_colorbar_in = iFlag_colorbar_in,
iFont_size_in = iFont_size_in,
iFlag_scientific_notation_colorbar_in = iFlag_scientific_notation_colorbar_in,
dData_max_in = dData_max,
dData_min_in = dData_min,
sFilename_output_in=sFilename_output_in,
sVariable_in= sVariable,
sTitle_in= sTitle,
Expand Down
24 changes: 19 additions & 5 deletions pyflowline/external/pyearth/visual/map/map_multiple_vector_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def map_multiple_vector_data(aFiletype_in,
aVariable_in = None,
sFilename_output_in=None,
iFlag_scientific_notation_colorbar_in=None,
iFont_size_in=None,
sColormap_in = None,
sTitle_in = None,
iDPI_in = None,
Expand Down Expand Up @@ -154,6 +155,11 @@ def map_multiple_vector_data(aFiletype_in,
else:
iFlag_title=0
sTitle = ''

if iFont_size_in is not None:
iFont_size = iFont_size_in
else:
iFont_size = 12

if sExtend_in is not None:
sExtend = sExtend_in
Expand Down Expand Up @@ -203,7 +209,13 @@ def map_multiple_vector_data(aFiletype_in,
dLon_min = np.min( [dLon_min, np.min(aCoords_gcs[:,0])] )
dLat_max = np.max( [dLat_max, np.max(aCoords_gcs[:,1])] )
dLat_min = np.min( [dLat_min, np.min(aCoords_gcs[:,1])] )

else:
if sGeometry_type =='LINESTRING':
aCoords_gcs = get_geometry_coords(pGeometry_in)
dLon_max = np.max( [dLon_max, np.max(aCoords_gcs[:,0])] )
dLon_min = np.min( [dLon_min, np.min(aCoords_gcs[:,0])] )
dLat_max = np.max( [dLat_max, np.max(aCoords_gcs[:,1])] )
dLat_min = np.min( [dLat_min, np.min(aCoords_gcs[:,1])] )

if pProjection_map_in is not None:
pProjection_map = pProjection_map_in
Expand Down Expand Up @@ -364,8 +376,8 @@ def map_multiple_vector_data(aFiletype_in,
lID = lID + 1

if aExtent_in is None:
marginx = (dLon_max - dLon_min) / 20
marginy = (dLat_max - dLat_min) / 20
marginx = (dLon_max - dLon_min) / 50
marginy = (dLat_max - dLat_min) / 50
aExtent = [dLon_min - marginx , dLon_max + marginx , dLat_min -marginy , dLat_max + marginy]
else:
aExtent = aExtent_in
Expand All @@ -377,13 +389,15 @@ def map_multiple_vector_data(aFiletype_in,

if aLegend_in is not None:
nlegend = len(aLegend_in)
dLocation0 = 0.96
for i in range(nlegend):
sText = aLegend_in[i]
dLocation = 0.06 + i * 0.04
#dLocation = 0.06 + i * 0.04
dLocation = dLocation0 - i * 0.06
ax.text(0.03, dLocation, sText,
verticalalignment='top', horizontalalignment='left',
transform=ax.transAxes,
color='black', fontsize=6)
color='black', fontsize=iFont_size)

pass

Expand Down

0 comments on commit 8ec2f66

Please sign in to comment.