diff --git a/src/siphon/simplewebservice/wyoming.py b/src/siphon/simplewebservice/wyoming.py index 639dc8de7..835a9cb0c 100644 --- a/src/siphon/simplewebservice/wyoming.py +++ b/src/siphon/simplewebservice/wyoming.py @@ -28,7 +28,7 @@ def __init__(self): super().__init__('http://weather.uwyo.edu/cgi-bin/sounding') @classmethod - def request_data(cls, time, site_id, **kwargs): + def request_data(cls, time, site_id, recalc=False, **kwargs): r"""Retrieve upper air observations from the Wyoming archive. Parameters @@ -40,6 +40,11 @@ def request_data(cls, time, site_id, **kwargs): The three letter ICAO identifier of the station for which data should be downloaded. + recalc : bool + Whether to request the server recalculate the data (i.e. ignore its cache) before + returning it. Defaults to False. NOTE: This should be used sparingly because it + will increase the load on the service. + kwargs Arbitrary keyword arguments to use to initialize source @@ -50,10 +55,10 @@ def request_data(cls, time, site_id, **kwargs): """ endpoint = cls() - df = endpoint._get_data(time, site_id) + df = endpoint._get_data(time, site_id, recalc=recalc) return df - def _get_data(self, time, site_id): + def _get_data(self, time, site_id, recalc=False): r"""Download and parse upper air observations from an online archive. Parameters @@ -65,12 +70,15 @@ def _get_data(self, time, site_id): The three letter ICAO identifier of the station for which data should be downloaded. + recalc : bool + Returns recalculated data if True. Defaults to False. + Returns ------- `pandas.DataFrame` """ - raw_data = self._get_data_raw(time, site_id) + raw_data = self._get_data_raw(time, site_id, recalc=recalc) soup = BeautifulSoup(raw_data, 'html.parser') tabular_data = StringIO(soup.find_all('pre')[0].contents[0]) col_names = ['pressure', 'height', 'temperature', 'dewpoint', 'direction', 'speed'] @@ -129,7 +137,7 @@ def _get_data(self, time, site_id): return df - def _get_data_raw(self, time, site_id): + def _get_data_raw(self, time, site_id, recalc=False): """Download data from the University of Wyoming's upper air archive. Parameters @@ -138,6 +146,8 @@ def _get_data_raw(self, time, site_id): Date and time for which data should be downloaded site_id : str Site id for which data should be downloaded + recalc : bool + Returns recalculated data if True. Defaults to False. Returns ------- @@ -148,6 +158,8 @@ def _get_data_raw(self, time, site_id): path = ('?region=naconf&TYPE=TEXT%3ALIST' f'&YEAR={time:%Y}&MONTH={time:%m}&FROM={time:%d%H}&TO={time:%d%H}' f'&STNM={site_id}') + if recalc: + path += '&REPLOT=1' resp = self.get_path(path) # See if the return is valid, but has no data