@@ -310,7 +310,7 @@ def pymodis_download(wdir, vert, horiz, STARTDATE, ENDDATE):
310
310
hreg = ("h" + f"{ horiz :02d} " ) # re.compile("h2[4]")
311
311
vreg = ("v" + f"{ vert :02d} " ) # re.compile("v0[5]")
312
312
TILE = hreg + vreg
313
- print ("Downloading " + product + " from " + STARTDATE + " to " + ENDDATE )
313
+ print ("Downloading " + PRODUCT + " from " + STARTDATE + " to " + ENDDATE )
314
314
os .system ("modis_download.py -U " +
315
315
USER +
316
316
" -P " + PWD +
@@ -877,7 +877,7 @@ def fsca_plots(wdir, plotDay, df_mean):
877
877
for i in range (0 , nclust ):
878
878
lookup [i ] = df_mean [i ]
879
879
880
- with rasterio .open ('landform.tif' ) as src :
880
+ with rio .open ('landform.tif' ) as src :
881
881
# Read as numpy array
882
882
array = src .read ()
883
883
profile = src .profile
@@ -894,7 +894,7 @@ def fsca_plots(wdir, plotDay, df_mean):
894
894
895
895
with rio .open ('output_raster.tif' , 'w' , ** profile ) as dst :
896
896
# Write to disk
897
- dst .write (array .astype (rasterio .int16 ))
897
+ dst .write (array .astype (rio .int16 ))
898
898
899
899
src1 = rio .open ("output_raster.tif" )
900
900
rio .plot .show (src1 , ax = axhist )
@@ -1003,7 +1003,7 @@ def da_compare_plot(wdir, plotDay, df_mean_open, df_mean_da):
1003
1003
for i in range (0 , nclust ):
1004
1004
lookup [i ] = df_mean_open [i ]
1005
1005
1006
- with rasterio .open ('landform.tif' ) as src :
1006
+ with rio .open ('landform.tif' ) as src :
1007
1007
# Read as numpy array
1008
1008
array = src .read ()
1009
1009
profile = src .profile
@@ -1015,12 +1015,12 @@ def da_compare_plot(wdir, plotDay, df_mean_open, df_mean_da):
1015
1015
#array[array > 0] = 1
1016
1016
1017
1017
1018
- # rasterio .plot.show(array, cmap='viridis')
1018
+ # rio .plot.show(array, cmap='viridis')
1019
1019
# plt.show()
1020
1020
1021
1021
with rio .open ('output_raster.tif' , 'w' , ** profile ) as dst :
1022
1022
# Write to disk
1023
- dst .write (array .astype (rasterio .int16 ))
1023
+ dst .write (array .astype (rio .int16 ))
1024
1024
1025
1025
src1 = rio .open ("output_raster.tif" )
1026
1026
rio .plot .show (src1 , ax = axopen )
@@ -1040,7 +1040,7 @@ def da_compare_plot(wdir, plotDay, df_mean_open, df_mean_da):
1040
1040
for i in range (0 , nclust ):
1041
1041
lookup [i ] = df_mean_da [i ]
1042
1042
1043
- with rasterio .open ('landform.tif' ) as src :
1043
+ with rio .open ('landform.tif' ) as src :
1044
1044
# Read as numpy array
1045
1045
array = src .read ()
1046
1046
profile = src .profile
@@ -1052,12 +1052,12 @@ def da_compare_plot(wdir, plotDay, df_mean_open, df_mean_da):
1052
1052
#array[array > 0] = 1
1053
1053
1054
1054
1055
- # rasterio .plot.show(array, cmap='viridis')
1055
+ # rio .plot.show(array, cmap='viridis')
1056
1056
# plt.show()
1057
1057
1058
1058
with rio .open ('output_raster.tif' , 'w' , ** profile ) as dst :
1059
1059
# Write to disk
1060
- dst .write (array .astype (rasterio .int16 ))
1060
+ dst .write (array .astype (rio .int16 ))
1061
1061
1062
1062
src1 = rio .open ("output_raster.tif" )
1063
1063
rio .plot .show (src1 , ax = axda )
@@ -1128,6 +1128,7 @@ def getModisbbox(Npixel, arr):
1128
1128
bbox = [xmax ,xmin , ymax , ymin ]
1129
1129
return bbox
1130
1130
1131
+ '''
1131
1132
def getSamples_inModisPixel(map_path):
1132
1133
"""
1133
1134
Identify samples that exist within a single bbox and proportianal cover. This can be used to construct a modelled fSCA in a MODIS pixel
@@ -1145,12 +1146,12 @@ def getSamples_inModisPixel(map_path):
1145
1146
# # project
1146
1147
# x2, y2 = proj.transform(x_coord, y_coord)
1147
1148
# open map
1148
- dataset = rasterio .open (map_path )
1149
+ dataset = rio .open(map_path)
1149
1150
# get pixel x+y of the coordinate
1150
1151
py, px = dataset.index(x2, y2)
1151
1152
# create 1x1px window of the pixel
1152
- window = rasterio .windows .Window (px - 1 // 2 , py - 1 // 2 , 1 , 1 )
1153
+ window = rio .windows.Window(px - 1 // 2, py - 1 // 2, 1, 1)
1153
1154
# read rgb values of the window
1154
1155
clip = dataset.read(window=window)
1155
1156
return (int(clip))
1156
-
1157
+ '''
0 commit comments