Skip to content

Commit 312e085

Browse files
committed
corrected undefined variables detected by flake8 package. Two issue open: #77 and #76. [trigger test]
1 parent 5043db1 commit 312e085

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

TopoPyScale/topo_da.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def pymodis_download(wdir, vert, horiz, STARTDATE, ENDDATE):
310310
hreg = ("h" + f"{horiz:02d}") # re.compile("h2[4]")
311311
vreg = ("v" + f"{vert:02d}") # re.compile("v0[5]")
312312
TILE = hreg + vreg
313-
print("Downloading " + product + " from " + STARTDATE + " to " + ENDDATE)
313+
print("Downloading " + PRODUCT + " from " + STARTDATE + " to " + ENDDATE)
314314
os.system("modis_download.py -U " +
315315
USER +
316316
" -P " + PWD +
@@ -877,7 +877,7 @@ def fsca_plots(wdir, plotDay, df_mean):
877877
for i in range(0, nclust):
878878
lookup[i] = df_mean[i]
879879

880-
with rasterio.open('landform.tif') as src:
880+
with rio.open('landform.tif') as src:
881881
# Read as numpy array
882882
array = src.read()
883883
profile = src.profile
@@ -894,7 +894,7 @@ def fsca_plots(wdir, plotDay, df_mean):
894894

895895
with rio.open('output_raster.tif', 'w', **profile) as dst:
896896
# Write to disk
897-
dst.write(array.astype(rasterio.int16))
897+
dst.write(array.astype(rio.int16))
898898

899899
src1 = rio.open("output_raster.tif")
900900
rio.plot.show(src1, ax=axhist)
@@ -1003,7 +1003,7 @@ def da_compare_plot(wdir, plotDay, df_mean_open, df_mean_da):
10031003
for i in range(0, nclust):
10041004
lookup[i] = df_mean_open[i]
10051005

1006-
with rasterio.open('landform.tif') as src:
1006+
with rio.open('landform.tif') as src:
10071007
# Read as numpy array
10081008
array = src.read()
10091009
profile = src.profile
@@ -1015,12 +1015,12 @@ def da_compare_plot(wdir, plotDay, df_mean_open, df_mean_da):
10151015
#array[array > 0] = 1
10161016

10171017

1018-
# rasterio.plot.show(array, cmap='viridis')
1018+
# rio.plot.show(array, cmap='viridis')
10191019
# plt.show()
10201020

10211021
with rio.open('output_raster.tif', 'w', **profile) as dst:
10221022
# Write to disk
1023-
dst.write(array.astype(rasterio.int16))
1023+
dst.write(array.astype(rio.int16))
10241024

10251025
src1 = rio.open("output_raster.tif")
10261026
rio.plot.show(src1, ax=axopen)
@@ -1040,7 +1040,7 @@ def da_compare_plot(wdir, plotDay, df_mean_open, df_mean_da):
10401040
for i in range(0, nclust):
10411041
lookup[i] = df_mean_da[i]
10421042

1043-
with rasterio.open('landform.tif') as src:
1043+
with rio.open('landform.tif') as src:
10441044
# Read as numpy array
10451045
array = src.read()
10461046
profile = src.profile
@@ -1052,12 +1052,12 @@ def da_compare_plot(wdir, plotDay, df_mean_open, df_mean_da):
10521052
#array[array > 0] = 1
10531053

10541054

1055-
# rasterio.plot.show(array, cmap='viridis')
1055+
# rio.plot.show(array, cmap='viridis')
10561056
# plt.show()
10571057

10581058
with rio.open('output_raster.tif', 'w', **profile) as dst:
10591059
# Write to disk
1060-
dst.write(array.astype(rasterio.int16))
1060+
dst.write(array.astype(rio.int16))
10611061

10621062
src1 = rio.open("output_raster.tif")
10631063
rio.plot.show(src1, ax=axda)
@@ -1128,6 +1128,7 @@ def getModisbbox(Npixel, arr):
11281128
bbox = [xmax,xmin, ymax, ymin]
11291129
return bbox
11301130

1131+
'''
11311132
def getSamples_inModisPixel(map_path):
11321133
"""
11331134
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):
11451146
# # project
11461147
# x2, y2 = proj.transform(x_coord, y_coord)
11471148
# open map
1148-
dataset = rasterio.open(map_path)
1149+
dataset = rio.open(map_path)
11491150
# get pixel x+y of the coordinate
11501151
py, px = dataset.index(x2, y2)
11511152
# 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)
11531154
# read rgb values of the window
11541155
clip = dataset.read(window=window)
11551156
return (int(clip))
1156-
1157+
'''

TopoPyScale/topo_export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- SPHY forcing (grids)
88
"""
99
import pdb
10-
import sys
10+
import sys, csv
1111
import numpy as np
1212
import pandas as pd
1313
import datetime as dt

TopoPyScale/topo_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ def FsmSnowParser(file, freq="1H", resample=False):
4141
return (df)
4242

4343

44-
def FsmPlot(df):
45-
df.plot(subplots=True)
46-
plt.title("Sample=" + str(sampleN) + " Elev=" + str(np.round(lp.elevation[sampleN])))
47-
plt.show()
44+
#def FsmPlot(df):
45+
# df.plot(subplots=True)
46+
# plt.title("Sample=" + str(sampleN) + " Elev=" + str(np.round(lp.elevation[sampleN])))
47+
# plt.show()
4848

4949
def FsmPlot_ensemble(wdir, simvar, sampleN):
5050
"""

TopoPyScale/topoclass.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ def get_WMO_observations(self):
569569
df['year'] = df.dates.dt.year
570570

571571
bbox = [latS, lonW, latN, lonE]
572-
for year in years:
572+
for year in df.year.unique():
573573
# API only accept one year request
574574
tpo.fetch_WMO_insitu_observations(years=year,
575575
months=list(df.month.unique().astype(str)),

0 commit comments

Comments
 (0)