[docs]defobtain_paths(location):"""Obtain the correct name for the data files Args: location (string): Location identifier Raises: ValueError: If location identifier is not defined Returns: List[string]: Naming for the data files """if'az'inlocation.lower():return['AZ','USA_AZ_Phoenix-Sky.Harbor.epw']elif'ca'inlocation.lower():return['CA','USA_CA_San.Jose-Mineta.epw']elif'ga'inlocation.lower():return['GA','USA_GA_Atlanta-Hartsfield-Jackson.epw']elif'il'inlocation.lower():return['IL','USA_IL_Chicago.OHare.epw']elif'ny'inlocation.lower():return['NY','USA_NY_New.York-LaGuardia.epw']elif'tx'inlocation.lower():return['TX','USA_TX_Dallas-Fort.Worth.epw']elif'va'inlocation.lower():return['VA','USA_VA_Leesburg.Exec.epw']elif"wa"inlocation.lower():return['WA','USA_WA_Seattle-Tacoma.epw']else:raiseValueError(f"Location not found, please define the location {location} on obtain_paths() function in utils_cf.py")
[docs]defget_energy_variables(state):"""Obtain energy variables from the energy observation Args: state (List[float]): agent_dc observation Returns: List[float]: Subset of the agent_dc observation """energy_vars=np.hstack((state[4:7],(state[7]+state[8])/2))returnenergy_vars
# Function to get the initial index of the day of a given month from a time-stamped dataset
[docs]defget_init_day(start_month=0):"""Obtain the initial day of the year to start the episode on Args: start_month (int, optional): Starting month. Defaults to 0. Returns: int: Day of the year corresponding to the first day of the month """assert0<=start_month<=11,"start_month should be between 0 and 11 (inclusive, 0-based, 0=January, 11=December)."# Read the CSV file and parse dates from the 'timestamp' columndf=pd.read_csv(PATH+'/data/CarbonIntensity/NY_NG_&_avgCI.csv',parse_dates=['timestamp'],usecols=['timestamp'])# Extract the month from each timestamp and add it as a new column to the DataFramedf['month']=pd.DatetimeIndex(df['timestamp']).month# Find the first day of the specified start monthinit_day=df[df['month']==start_month+1].index[0]# Return the day number (0-based)returnint(init_day/24)