I am dealing with monthly data for a number of different data sets (e.g. air temperature, ocean temperature, wind speeds etc), whereby each month and each data set will share similar attributes. I want to be able to initialise and populate these attributes as efficiently as possible. So far I can only think of trying to somehow append new attributes to pre-existing attributes. Is this possible in Python?
For example, let's say I initialise all my monthly variables like the following:
class Data_Read:
def __init__(self, monthly=np.zeros((200,200,40))): #3D data
self.jan = monthly
self.feb = monthly
self.march = monthly
self.april = monthly
self.may = monthly
self.june = monthly
self.july = monthly
self.august = monthly
self.sept = monthly
self.oct = monthly
self.nov = monthly
self.dec = monthly
Then I can create a new data set for each month which will become something like air_temp.jan
or wind_speed.june
by doing the following:
air_temp = Data_Read()
wind_speed = Data_Read()
These would be the raw data attributes. However I would then like to do some processing to each of these data sets (like de-trending). Is there a way I can create a class (or a new class?) that will generate new attributes like self.jan.detrend
. Basically I want to avoid having to write 12 lines of code for every attribute I want to create, and then be able to easily call any "attribute of the attribute" in my data processing functions thereafter.
Many thanks.