# Get POI stations try: stations = pd.read_csv( POI_PATH, dtype="str", skiprows=skip, nrows=STATIONS_PER_CYCLE, names=["id"], ) except pd.errors.EmptyDataError: pass # Update counter if stations is None or len(stations.index) < STATIONS_PER_CYCLE: jsp.set_var("station_counter", 0) sys.exit() else: jsp.set_var("station_counter", skip + STATIONS_PER_CYCLE) # DataFrame which holds all data df_full = None # Import data for each weather station # pylint: disable=no-member for station in stations.to_dict(orient="records"): try: # Read CSV data from DWD server url = f"http://opendata.dwd.de/weather/weather_reports/poi/{station['id']}-BEOB.csv" df = pd.read_csv( url,
# Get ISD Lite stations try: stations = pd.read_csv( USAF_WBAN_PATH, dtype="str", skiprows=skip, nrows=STATIONS_PER_CYCLE, names=["id", "usaf", "wban"], ) except pd.errors.EmptyDataError: pass # Update counter if stations is None or len(stations.index) < STATIONS_PER_CYCLE: # Reset counter jsp.set_var("station_counter", 0) # Reset year if MODE == "historical": if year >= jsp.CURRENT_YEAR - 2: jsp.set_var("year", 1901) else: jsp.set_var("year", year + 1) sys.exit() else: jsp.set_var("station_counter", skip + STATIONS_PER_CYCLE) # Connect to NOAA FTP Server ftp = FTP("ftp.ncdc.noaa.gov") ftp.login() # Get list of years
MODE = sys.argv[1] # Create Jasper instance jsp = Jasper(f"export.bulk.gridded.daily.{MODE}") # Variables modified: bool = None raw: pd.DataFrame # Get time delta if MODE == "historical": # We'll need to run at least twice a day # Otherwise this is stuck delta = jsp.get_var("date_offset", 0, int) if delta > 18493: jsp.set_var("date_offset", 0) sys.exit() jsp.set_var("date_offset", delta + 1) else: delta = int(sys.argv[2]) # Get date date = datetime.date.today() - datetime.timedelta(days=delta) # Get modification time try: modified = (jsp.bulk().voidcmd(f"""MDTM /gridded/daily/tavg/{ date.strftime("%Y-%m-%d") }.nc""")[4:].strip()) except BaseException: pass