Ejemplo n.º 1
0
    def load(self):
        """
        あったらロード、なかったら作ってセーブ
        """
        try:
            Xt = subroutine.load_npz('True' + self.fname)
            Xo = subroutine.load_npz('Obs' + self.fname)
        except FileNotFoundError:
            Xt, Xo = self.make()
            self.save(Xt, Xo)

        return Xt, Xo
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 load_climatology_or_interannual_variation_as_npz(fy, ly, month, var, Ave_or_Std, product_n = 3):
	vid = Var.var_to_id(var)
	formal_name = Var.VAR[vid].Get_formal_name()
	title_name = D.Data[product_n].title_name
	_, strmonth = subroutine.strym(2000, month)
	data =subroutine.load_npz(Ave_or_Std + '_of_' + \
							  formal_name + '_m' + strmonth + '_' + str(fy) + '-' + str(ly) + \
							  '_' + title_name)
	return data
Ejemplo n.º 4
0
	def load_data_of_npz(self, fy, ly, var, depth = 1, product_n = 3):
		import D
		import Var
		import subroutine
		vid = Var.var_to_id(var)
		formal_name = Var.VAR[vid].Get_formal_name()
		title_name = D.Data[product_n].title_name
		xgrid, ygrid, zgrid = D.get_grid_value(var, product_n)
		Timeseries = subroutine.load_npz(self.AreaName + '_Area-Averaged-' + \
										 formal_name + '_at_' + str(zgrid[depth - 1]) + \
										 'm_Year' + str(fy) + '-' + str(ly) + '_' + title_name)
		months, label = subroutine.get_months_and_label(fy, ly)
		return Timeseries, months, label
Ejemplo n.º 5
0
	def load_Data_of_Climatology_of_npz(self, month, fy, ly, product_n):
		import D
		import subroutine
		title_name = D.Data[product_n].title_name
		year = 2000
		stryear, strmonth = subroutine.strym(year, month)
		DIR = subroutine.NAS_dir() + 'DATA/' + title_name + '/npz/' + self.dir_name + '/'
		_, strmonth = subroutine.strym(year, month)
		Data_of_Clim = subroutine.load_npz(DIR + self.fname + '_of_Climatology_Year' + \
										   str(fy) + '-' + str(ly) + \
										   '_Month' + strmonth + '_' + title_name, \
										   data_dir_flg = 'NO')

		return Data_of_Clim
Ejemplo n.º 6
0
	def load_Ave_or_Std_of_Data_of_npz(self, month, fy, ly, product_n, Ave_or_Std = 'Ave'):
		import D
		import subroutine
		title_name = D.Data[product_n].title_name
		year = 2000
		stryear, strmonth = subroutine.strym(year, month)
		DIR = subroutine.NAS_dir() + 'DATA/' + title_name + '/npz/' + self.dir_name + '/'
		_, strmonth = subroutine.strym(year, month)
		AvSt_of_Data = subroutine.load_npz(DIR +  Ave_or_Std + '_of_' + self.fname + '_Year' + \
										   str(fy) + '-' + str(ly) + \
										   '_Month' + strmonth + '_' + title_name, \
										   data_dir_flg = 'NO')

		return AvSt_of_Data
Ejemplo n.º 7
0
	def load_data_of_npz(self, fy, ly, var = 's', depthn = 1, product_n = 3, Rawdata_or_Anomaly = 'Rawdata', fy_of_Anomalydata = 1990, ly_of_Anomalydata = 2011):
		import D
		import subroutine
		import Var
		title_name = D.Data[product_n].title_name
		xgrid, ygrid, zgrid = D.get_grid_value('s', product_n)
		vid = Var.var_to_id(var)
		formal_name = Var.VAR[vid].Get_formal_name()

		if Rawdata_or_Anomaly == 'Rawdata':
			fname_RA = formal_name
		elif Rawdata_or_Anomaly == 'Anomaly':
			fname_RA = '[Anomaly_of_' + formal_name + str(fy_of_Anomalydata) + '-' + str(ly_of_Anomalydata) + ']'
		else:
			raise ValueError('your Rawdata_or_Anomaly argument is not valid!')

		Timeseries = subroutine.load_npz(self.AreaName + '_of_' + fname_RA + '_at_' + str(zgrid[depthn - 1]) + \
										 'm_Year' + str(fy) + '-' + str(ly) + '_' + title_name)
		months, label = subroutine.get_months_and_label(fy, ly)
		return Timeseries, months, label
def load_Anomaly_of_npz(year, month, var, fy = 1990, ly = 2011, product_n = 3):
	a = subroutine.read_meta_data('var')
	formal_name = subroutine.celldata(a, 'var', var, 'formal_name')
	DIR = subroutine.get_DIR(year, month, formal_name, product_n)
	data = subroutine.load_npz(DIR + 'Anomaly_from_Mean_Annual_Cycle_Year' + str(fy) + '-' + str(ly), data_dir_flg = 'NO')
	return data
Ejemplo n.º 9
0
	def load_data_of_npz(self, year, month, product_n):
		import subroutine
		DIR = subroutine.get_DIR(year, month, self.dir_name, product_n)
		data = subroutine.load_npz(DIR + self.fname, data_dir_flg = 'NO')
		return data
Ejemplo n.º 10
0
#coding:utf-8

# 2016/11/22作成。
# jitを用いる関数は全部ここに固める。
import numpy as np
from numba import jit, f8
import D
import subroutine
Mt = 60 * 60 * 24 * 30
zgrid = subroutine.load_npz('zgrid_of_ESTOCver03')
zn = zgrid.size
lz = subroutine.layer_length()


@jit(f8(f8))
def use_jit(N):
	n = 0
	for i in range(N):
		for j in range(N):
			n += i + j

	return n


def unuse_jit(N):
	n = 0
	for i in range(N):
		for j in range(N):
			n += i + j

	return n
Ejemplo n.º 11
0
	def load_Area_Trimmed_data_of_npz(self, year, month, dname, fname, product_n):
		import subroutine
		DIR = subroutine.get_DIR(year, month, dname, product_n)
		data = subroutine.load_npz(DIR + fname + '_trimmed_at_' + self.AreaName, data_dir_flg = 'NO')
		return data
Ejemplo n.º 12
0
	def load_UV_of_VerticalSection_of_npz(self, year, month, product_n):
		import subroutine
		DIR = subroutine.get_DIR(year, month, 'Current', product_n)
		Data = subroutine.load_npz(DIR + 'UV_of_VerticalSection_of_' + self.AreaName, data_dir_flg = 'NO')
		return Data
Ejemplo n.º 13
0
	def load_Vertical_section_of_data_of_npz(self, year, month, dname, fname, product_n):
		import subroutine
		DIR = subroutine.get_DIR(year, month, dname, product_n)
		data = subroutine.load_npz(DIR + fname + '_VerticalSection_of_' + self.AreaName, data_dir_flg = 'NO')
		return data