Esempio n. 1
0
def compute(temperature, pressure, humidity, windspeed, winddirn, sunrise,
            sunset, date, time, paramFile):
    pwrModel, params = parameters.read(paramFile)
    radiation = []
    for dataIndex in range(0, len(temperature)):
        leap = tm.isLeap(date)
        day = tm.dayInYear(date, leap)
        hour = tm.toDecHours(time)
        midday = (float(tm.toDecHours(sunrise)) +
                  float(tm.toDecHours(sunset))) / 2.0
        nominalRad = solarData.nominalRadiation(day, hour, midday, leap)
        #    print(leap,day,hour,midday,nominalRad)
        temp = float(temperature[dataIndex]) + 459.67
        press = float(pressure[dataIndex])
        humid = float(humidity[dataIndex]) / 100.0
        speed = float(windspeed[dataIndex])
        dirn = float(winddirn[dataIndex])
        #    print(temp,press,humid,speed,dirn)
        if pwrModel == "linear":
            model = computeNormRad.linear(temp, press, humid, speed, dirn,
                                          params)
        else:
            model = computeNormRad.quadratic(temp, press, humid, speed, dirn,
                                             params)
        radiation.append(max(0.0, nominalRad * (1.0 - model)))
    return radiation
Esempio n. 2
0
    def __init__(self, cfile='default.cfg'):
        if cfile == 'default.cfg':
            configuration_file = os.path.join(os.path.dirname(__file__), cfile)
        else:
            configuration_file = cfile
        atmosphere, zm, D, pixels, ngs_array, lgs_array, lgs_height =  parameters.read(configuration_file)
        self.Zernike = zernike.Zernike()
        self.pixdiam = pixels  #must be integer
        self.cn2 = atmosphere['cn2']
        self.h_profile = atmosphere['h_profile']
        self.pupil_diameter = D
        self.dr0 = atmosphere['dr0']
        self.large_scale = atmosphere['L0']
        self.nz1 = zm
        self.nz2 = zm
        self.ngspos = ngs_array
        self.lgspos = lgs_array
        self.hlgs = lgs_height
#        self.lgscoefmatrix = np.zeros((12, self.nz1-4, self.nz2-4)) #make as function of number of lgs
#        self.ngscoefmatrix = np.zeros((2,2,2))
#        self.propervectors = np.zeros((12, self.nz1-4, self.nz2-4))
#        self.propervalues = np.zeros((12, self.nz1-4))
        self.rho, self.phi, self.mask = polar2(self.pixdiam/2., fourpixels=True, length=self.pixdiam)
        self.zernikes = np.zeros((self.nz1-2, self.pixdiam, self.pixdiam))
#        self.lgsvmatrices = np.zeros((15, self.nz1-4, 2*self.pixdiam, 2*self.pixdiam))   #make as function of number of lgs
        self.ngsvmatrices = np.zeros((2, 2, 2*self.pixdiam, 2*self.pixdiam))
#        self.lgsnewzernikes = np.zeros((15, self.nz1-4, self.pixdiam, self.pixdiam))
        self.ngsnewzernikes = np.zeros((2, 2, self.pixdiam, self.pixdiam))
        if self.nz1 > 980:
            self.zcoef_mask = compmask(self.nz1, self.nz2).T
        else:
            self.zcoef_mask = zcoef_mask
Esempio n. 3
0
import parameters as prms
import flagger as flg
import calibrator as clb
import casatasks as cts

# apply the calibrations on the target
params = prms.read('parameters.yaml')
target = params['general']['target']
gaintables = params['calibration']['gaintables']
'''
print('Applying the calibration tables to the target...') 
msfile = '../blcal_test/CGCG032-017_cen1K_split.ms'
uvran = '0.5~100klambda'
phasecal = '0745+101'
cts.applycal(msfile, field=target, uvrange=uvran, gaintable=gaintables, gainfield=['','',phasecal], interp=['','','linear'], calwt=[False], parang=False)


# rflag the data
print('Mildly Rflagging the target at cutoff of 10 sigma...')
flg.rflagger(msfile, params, field=target, tcut=10, fcut=10, instance='postcal')
flg.extend(msfile, params, field=target, grow=80, instance='postcal')
# split the calibrated target data
out_cal_file = '../blcal_test/RGG5_yarrp_cal.ms'#params['general']['targetcalfile']

print('Splitting the target...')
cts.mstransform(msfile, field=target, spw='0', chanaverage=False, datacolumn='corrected', outputvis=out_cal_file)


print('Doing uvsub...')
target = params['general']['target']
targetcalfile = '../blcal_test/RGG5_cen1k_yarrp_cal.ms' #params['general']['targetcalfile']
Esempio n. 4
0
import data
import lstm
import parameters
import plot


%matplotlib inline
%load_ext autoreload
%autoreload 2

# Initialization of seeds
set_random_seed(2)
seed(2)

# load json and create model
params = parameters.read()
raw = data.read(params)
print('Original dataset num samples:', raw.shape)
adjusted = parameters.adjust(raw, params)
X_train, Y_train, X_test, Y_test = data.prepare(adjusted, params)

# Build the model and train it.
params['lstm_batch_size'] = 1
model = lstm.build(params)

# load weights into new model
model.load_weights("20180116_0438.h5")
print("Loaded weights from disk")

print('Actual:', params['y_scaler'].inverse_transform(Y_test[31]))
Esempio n. 5
0
    full_cost = 0
    full_iterations = 0
    for i in range(0, n):
        ga = genetic(param_path, 'graph.txt', 2020)
        ga.init_pop()
        ga.sort()

        iterations, chrome = ga.evolve()
        # print 'total iterations:', iterations, 'chrome:', chrome, 'cost:', chrome.cost,
        full_cost += chrome.cost
        full_iterations += iterations

    print 'Average cost:', full_cost / n, "Iterations:", full_iterations / n


params = parameters.read(param_path)
print "Crossover:", params["CrossoverType"].upper(), "\nSelection:", params["SelectionType"].upper(), "\nMutation:", \
    params["MutateType"].upper()
test(TravelingSalesman_GA)
print '\n'

# print "Testing PMX with Tournament"
# test(TravelingSalesman_PMX_Tourn)
# print '\n'
#
# print "Testing PMX with Top Down"
# test(TravelingSalesman_PMX_TopDown)
# print '\n'
#
# print "Testing Cycle CX with Tournament"
# test(TravelingSalesman_CX_Tourn)
Esempio n. 6
0
 def __init__(self, param_path):
     self.params = parameters.read(param_path)
     self.chars = list(lowercase)  # Should be overwritten by subclass
     self.population = []
Esempio n. 7
0
 def __init__(self, param_path):
     self.params = parameters.read(param_path)
     self.genes = []  # Should be overwritten by subclass
     self.population = []