def from_M2D2(wmm_id, primary_ano=None, primary_vane=None, start_date=None, end_date=None): '''Download mast data and metadata from the met data database M2D2 (EDF specific). Currently this is only the 10-minute average of each installed sensor. Will add standard deviation, maximum, and minimum in the future. :Parameters: wmm_id: int Wind met mast id number in M2D2. To get a list of masts in M2D2 run the following:: import anemoi as an m2d2 = an.io.database.M2D2() m2d2.get_masts() primary_ano: string; default None Primary anemomter sensor name primary_vane: string; default None Primary wind vane sensor name start_date: string; default None Begining of the desired data period. If None, first available day is assumed. Date format: 'yyyy-mm-dd' ex:'2017-01-31' end_date: string; default None End of the desired data period. If None, present day is assumed from you computers clock. Date format: 'yyyy-mm-dd' ex:'2017-01-31' http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases :Returns: out: an.MetMast object ''' M2D2 = an.io.database.M2D2() mast_metadata = M2D2.get_wmm_id_metadata(wmm_id) lat = mast_metadata.loc[0, 'WMM_Latitude'] lon = mast_metadata.loc[0, 'WMM_Longitude'] elev = mast_metadata.loc[0, 'WMM_Elevation'] mast_data = M2D2.get_wmm_id_data(wmm_id, start_date=start_date, end_date=end_date) mast = an.MetMast(data=mast_data, elev=elev, lat=lat, lon=lon, name=wmm_id) return mast
def return_test_mast(): index = pd.date_range(start='2000-01-01', periods=52596, freq='10min') sensors = [ 'T_78_AVG', 'T_4_AVG', 'SPD_79_NW_AVG', 'SPD_79_SW_AVG', 'SPD_76_NW_AVG', 'SPD_57_NW_AVG', 'SPD_57_SW_AVG', 'SPD_34_NW_AVG', 'SPD_34_SW_AVG', 'DIR_76_AVG', 'DIR_30_AVG' ] mast_data = pd.DataFrame(index=index, columns=sensors, data=np.random.randn(len(index), len(sensors))) mast_data.columns.name = 'sensor' mast = an.MetMast(name=1, data=mast_data, lat=45, lon=-90, primary_ano='SPD_79_NW_AVG', primary_vane='DIR_76_AVG') return mast
def from_parquet_files(filename_data, filename_metadata): data = pd.read_parquet(filename_data) metadata = pd.read_parquet(filename_metadata).T name = metadata.columns[0] lat = metadata.loc['lat', name] lon = metadata.loc['lon', name] elev = metadata.loc['elev', name] height = metadata.loc['height', name] primary_ano = metadata.loc['primary_ano', name] primary_vane = metadata.loc['primary_vane', name] mast = an.MetMast(data=data, name=name, lat=lat, lon=lon, elev=elev, height=height, primary_ano=primary_ano, primary_vane=primary_vane) return mast
def mast_from_wmm_id(self, wmm_id): '''Download an.MetMast from M2D2 :Parameters: wmm_id: int Mast ID (wmm_id) in M2D2 :Returns: out: an.MetMast with data and metadata from M2D2 ''' print(f'Downloading Mast {wmm_id} from M2D2') data = self.data_from_mast_wmm_id(wmm_id=wmm_id) metadata = self.metadata_from_mast_wmm_id(wmm_id=wmm_id) mast = an.MetMast(data=data, name=wmm_id, lat=metadata.WMM_Latitude[0], lon=metadata.WMM_Longitude[0], elev=metadata.WMM_Elevation[0]) return mast