mattritchey commited on
Commit
3e625c8
1 Parent(s): 1359579

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +13 -11
main.py CHANGED
@@ -18,6 +18,17 @@ app = FastAPI()
18
  @app.get("/")
19
  def root():
20
  return {"API": "ACPC HRRR"}
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  def geocode_address(address):
23
 
@@ -54,19 +65,10 @@ def get_data(address, start_date, end_date, radius_miles, get_max):
54
 
55
  # Convert Lat Lon to row & col on Array
56
  try:
57
- crs_dic = pickle.load(open('Data/hrrr_crs.pkl', 'rb'))
58
- except:
59
- crs_dic=None
60
- try:
61
- transform = crs_dic['affine']
62
- trans_hrrr = crs_dic['proj_4326']
63
- lon_hrrr, lat_hrrr = trans_hrrr.transform(lon, lat)
64
-
65
- row, col = rasterio.transform.rowcol(transform, lon_hrrr, lat_hrrr)
66
- row, col = int(row), int(col)
67
  except:
68
  row=col=None
69
-
70
 
71
  # files = [
72
  # # 'Data/APCP_2024_hrrr_v2.h5',
 
18
  @app.get("/")
19
  def root():
20
  return {"API": "ACPC HRRR"}
21
+
22
+
23
+ def lat_lon_to_row_col(lat, lon):
24
+ crs_dic = pickle.load(open('Data/hrrr_crs.pkl', 'rb'))
25
+ transform = crs_dic['affine']
26
+ trans_rtma = crs_dic['proj_4326']
27
+ lon_rtma, lat_rtma = trans_rtma.transform(lon, lat)
28
+
29
+ row, col = rasterio.transform.rowcol(transform, lon_rtma, lat_rtma)
30
+ row, col = int(row), int(col)
31
+ return row, col
32
 
33
  def geocode_address(address):
34
 
 
65
 
66
  # Convert Lat Lon to row & col on Array
67
  try:
68
+ row, col = lat_lon_to_row_col(lat, lon)
 
 
 
 
 
 
 
 
 
69
  except:
70
  row=col=None
71
+
72
 
73
  # files = [
74
  # # 'Data/APCP_2024_hrrr_v2.h5',