def save_Data_of_Climatology_as_npz(self, Data_of_Clim, fy, ly, product_n): """ Data_of_Climの作成は、以下のような感じで。 Data_of_Clim = np.zeros((ygrid.size, xgrid.size, 12)) for month in range(1, 13): # SGT of Ave t = CI.load_climatology_or_interannual_variation_as_npz(fy, ly, month, 't', 'Ave', product_n = product_n) s = CI.load_climatology_or_interannual_variation_as_npz(fy, ly, month, 's', 'Ave', product_n = product_n) Data_of_Clim[:, :, month - 1] = make_density_product_from_ts(t, s, product_n = product_n, data_type = 1) """ import D import subroutine title_name = D.Data[product_n].title_name year = 2000 DIR = subroutine.NAS_dir() + 'DATA/' + title_name + '/npz/' + self.dir_name + '/' subroutine.check_and_make_DIR(DIR) for month in range(1, 13): _, strmonth = subroutine.strym(year, month) fname = self.fname + '_of_Climatology_Year' + \ str(fy) + '-' + str(ly) + \ '_Month' + strmonth + '_' + title_name if self.dimension == 2: subroutine.save_npz(Data_of_Clim[:, :, month - 1], DIR + fname, data_dir_flg = 'NO') elif self.dimension == 3: subroutine.save_npz(Data_of_Clim[:, :, :, month - 1], DIR + fname, data_dir_flg = 'NO') else: raise ValueError('your dimension is not valid!')
def save_Anomaly_as_npz(fy, ly, var, product_n = 3): a = subroutine.read_meta_data('var') formal_name = subroutine.celldata(a, 'var', var, 'formal_name') dim = subroutine.celldata(a, 'var', var, 'dim') _,title_name,_=subroutine.product_n_to_name(product_n) tmpyear = 2000 for month in range(1,13): _,strmonth=subroutine.strym(2000,month) Clim=subroutine.load_npz('Ave_of_' + formal_name + '_m'+strmonth+'_' + str(fy) + '-' + str(ly) + '_'+title_name) print 'month = ', month start = time.time() for year in range(fy,ly+1): stryear,strmonth=subroutine.strym(year,month) j=year-fy if dim == '3D': data=subroutine.get_data(year,month,var,0,title_name) elif dim == '2D': data=subroutine.get_data(year,month,var,1,title_name) else: raise Exception('your dim is not valid!') Anomaly=data-Clim DIR = subroutine.get_DIR(year, month, formal_name, product_n) subroutine.check_and_make_DIR(DIR) subroutine.save_npz(Anomaly,DIR+'Anomaly_from_Mean_Annual_Cycle_Year'+str(fy)+'-'+str(ly),data_dir_flg='NO') print 'elapsed time:', time.time() - start
def save_Vertical_section_of_data_as_npz(self, year, month, data, dname, fname, var, product_n): # 色んなデータの鉛直断面を保存することになるだろう。 # だから、dname,fnameは自分で設定できるようにしておく。 # dnameはD2.D2Data[~].dir_name、 # fnameはD2.D2Data[~].fnameが望ましいかと。 import subroutine Data, _, _ = self.Get_VerticalSection_from_data(data, var, product_n) DIR = subroutine.get_DIR(year, month, dname, product_n) subroutine.check_and_make_DIR(DIR) subroutine.save_npz(Data, DIR + fname + '_VerticalSection_of_' + self.AreaName, data_dir_flg = 'NO')
def save_Ave_or_Std_of_Data_as_npz(self, AvSt_of_Data, fy, ly, product_n, Ave_or_Std = 'Ave'): import D import subroutine title_name = D.Data[product_n].title_name year = 2000 DIR = subroutine.NAS_dir() + 'DATA/' + title_name + '/npz/' + self.dir_name + '/' subroutine.check_and_make_DIR(DIR) for month in range(1, 13): _, strmonth = subroutine.strym(year, month) fname = self.fname + '_of_Climatology_Year' + \ str(fy) + '-' + str(ly) + \ '_Month' + strmonth + '_' + title_name if self.dimension == 2: subroutine.save_npz(AvSt_of_Data[:, :, month - 1], DIR + fname, data_dir_flg = 'NO') elif self.dimension == 3: subroutine.save_npz(AvSt_of_Data[:, :, :, month - 1], DIR + fname, data_dir_flg = 'NO') else: raise ValueError('your dimension is not valid!')
def save_data_as_npz(self, year, month, data, product_n): import subroutine DIR = subroutine.get_DIR(year, month, self.dir_name, product_n) subroutine.check_and_make_DIR(DIR) subroutine.save_npz(data, DIR + self.fname, data_dir_flg = 'NO')
def save_Area_Trimmed_data_as_npz(self, data, year, month, dname, fname, product_n): import subroutine DIR = subroutine.get_DIR(year, month, dname, product_n) subroutine.check_and_make_DIR(DIR) subroutine.save_npz(data, DIR + fname + '_trimmed_at_' + self.AreaName, data_dir_flg = 'NO')
def save_UV_of_VerticalSection_as_npz(self, year, month, Data, product_n): import subroutine DIR = subroutine.get_DIR(year, month, 'Current', product_n) subroutine.check_and_make_DIR(DIR) subroutine.save_npz(Data, DIR + 'UV_of_VerticalSection_of_' + self.AreaName, data_dir_flg = 'NO')