Split BUFRSounding.latest() into separate methods
This commit is contained in:
parent
854cfa65e4
commit
17df1e1dba
1 changed files with 16 additions and 8 deletions
|
@ -82,8 +82,9 @@ class BUFRSounding(Sounding):
|
|||
DataAccessLayer.changeEDEXHost(BUFRSounding.EDEX_HOST)
|
||||
|
||||
@staticmethod
|
||||
def latest(station: str) -> Self:
|
||||
def create_request(station: str):
|
||||
request = DataAccessLayer.newDataRequest()
|
||||
request.setLocationNames(station)
|
||||
request.setDatatype(BUFRSounding.BUFR_TYPE)
|
||||
request.setParameters('staElev', 'staName')
|
||||
|
||||
|
@ -91,21 +92,20 @@ class BUFRSounding(Sounding):
|
|||
request.getParameters().extend(BUFRSounding.BUFR_PARAMS_SIGT)
|
||||
request.getParameters().extend(BUFRSounding.BUFR_PARAMS_SIGW)
|
||||
|
||||
request.setLocationNames(station)
|
||||
|
||||
datatimes = DataAccessLayer.getAvailableTimes(request)
|
||||
|
||||
response = DataAccessLayer.getGeometryData(request,
|
||||
times=datatimes[-1].validPeriod)
|
||||
return request
|
||||
|
||||
@staticmethod
|
||||
def request_sounding(request, period) -> Self:
|
||||
sounding = BUFRSounding()
|
||||
|
||||
response = DataAccessLayer.getGeometryData(request, times=period)
|
||||
|
||||
geom = response[0].getGeometry()
|
||||
dt = response[0].getDataTime()
|
||||
epoch = dt.getRefTime().time / 1000.0
|
||||
timestamp = datetime.datetime.fromtimestamp(epoch, datetime.UTC)
|
||||
|
||||
sounding.station = station
|
||||
sounding.station = response[0].getLocationName()
|
||||
sounding.data_source_pressure = 'UCAR'
|
||||
sounding.data_source_other = 'UCAR'
|
||||
sounding.location = shapely.Point(geom.x, geom.y)
|
||||
|
@ -147,3 +147,11 @@ class BUFRSounding(Sounding):
|
|||
sounding.samples.append(sounding.samples_by_height[height])
|
||||
|
||||
return sounding
|
||||
|
||||
@staticmethod
|
||||
def latest(station: str) -> Self:
|
||||
request = BUFRSounding.create_request(station)
|
||||
datatimes = DataAccessLayer.getAvailableTimes(request)
|
||||
|
||||
return BUFRSounding.request_sounding(request,
|
||||
datatimes[-1].validPeriod)
|
||||
|
|
Loading…
Add table
Reference in a new issue