File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed
Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -213,7 +213,7 @@ def process_main(args):
213213 date = args .start
214214 while date <= args .stop :
215215 for site_id in args .sites :
216- site = processor .get_site (site_id )
216+ site = processor .get_site (site_id , date )
217217 for product_id in args .products :
218218 product = processor .get_product (product_id )
219219 try :
Original file line number Diff line number Diff line change @@ -85,8 +85,8 @@ def process_task(self) -> bool:
8585 self .logger .clear_memory ()
8686 logging .info (f"Processing task: { task } " )
8787 try :
88- site = self .processor .get_site (task ["siteId" ])
8988 date = datetime .date .fromisoformat (task ["measurementDate" ])
89+ site = self .processor .get_site (task ["siteId" ], date )
9090 product = self .processor .get_product (task ["productId" ])
9191 params : ProcessParams
9292 with TemporaryDirectory () as directory :
Original file line number Diff line number Diff line change 66from pathlib import Path
77from typing import Literal
88
9+ import requests
910from cloudnetpy .exceptions import PlottingError
1011from cloudnetpy .model_evaluation .plotting .plotting import generate_L3_day_plots
1112from cloudnetpy .plotting import Dimensions , PlotParameters , generate_figure
@@ -93,8 +94,20 @@ def __init__(
9394 self .pid_utils = pid_utils
9495 self .dvas = dvas
9596
96- def get_site (self , site_id : str ) -> Site :
97+ def get_site (self , site_id : str , date : datetime . date | None = None ) -> Site :
9798 site = self .md_api .get (f"api/sites/{ site_id } " )
99+ if site ["latitude" ] is None and site ["longitude" ] is None :
100+ if date is None :
101+ raise ValueError ("Date and latitude/longitude not specified" )
102+ try :
103+ location = self .md_api .get (
104+ f"api/sites/{ site_id } /locations/{ date .isoformat ()} "
105+ )
106+ site ["latitude" ] = location ["latitude" ]
107+ site ["longitude" ] = location ["longitude" ]
108+ except requests .exceptions .HTTPError as err :
109+ if err .response .status_code != 404 :
110+ raise err
98111 return Site (
99112 id = site ["id" ],
100113 name = site ["humanReadableName" ],
You can’t perform that action at this time.
0 commit comments