Source code for pycif.plugins.datastreams.meteos.dummy_csv.make
import numpy as np
import pandas as pd
[docs]
def make(meteo, meteo_file, file_hours, **kwargs):
"""Creates random meteo time series for toy Gaussian model
Args:
meteo (pycif.utils.classes.Meteo): object defining the meteo
meteo_file (str): path where to dump
file_hours (pd.DatetimeIndex): list of dates to include
Returns:
initialized meteo
"""
ndates = len(file_hours)
# Initialize random seed if needed
# The seed is chosen from the one specified, plus the difference of time
# from the start of the inversion window
if meteo.seed:
np.random.seed(meteo.seed_id
+ int((file_hours.min() - meteo.datei).total_seconds()))
windspeed = np.random.uniform(0, 5, size=ndates)
winddir = np.random.uniform(0, 360, size=ndates)
stabclass = np.random.choice(["A", "B", "C", "D", "E", "F"], ndates)
df = pd.DataFrame(
data={
"windspeed": windspeed,
"winddir": winddir,
"stabclass": stabclass,
},
index=file_hours,
)
df.index.rename("date", inplace=True)
# Save to file
df.to_csv(meteo_file)