def __init__(self, value=0): self.val = RawValue('i', value) self.lock = threading.Lock()
print('finished!') def modifyUnit(argv): dataset = nc.Dataset(argv['distPath'], 'r+', format='NETCDF4') timeVariable = dataset.variables['time'] for var in dataset.variables: # 32年平均:1个时间切片;年平均:32个时间切片;32年的月平均:12个时间切片 if var.units == 'gC m-2 d-1' and \ timeVariable.shape[0] <= 32 and \ timeVariable.shape[0] != 12: var.units = 'kgC m-2 y-1' var[:] = var[:]*.365 dataset.close() print('finished!') counter = RawValue('i') counter.value = 0 average = False multiprocessing = True options, args = getopt.getopt(sys.argv[1:], '', ['model=', 'var=', 'step=', 'average=', 'multiprocessing=']) for opt in options: if(opt[0] == '--model'): model = opt[1] elif(opt[0] == '--var'): var = opt[1] elif(opt[0] == '--step'): step = int(opt[1]) elif(opt[0] == '--average'): # average = opt[1] in ['true', 'True', '1', 't', 'y'] average = True elif(opt[0] == '--multiprocessing'):
def __init__(self, value=0): self.val = RawValue('i', value) self.lock = Lock()
def __init__(self, initval=0): self.val = RawValue('i', initval) self.lock = Lock()
def __init__(self, initval=0): self.val = RawValue('i', initval) self.last_step_update_target = RawValue('i', initval) self.lock = Lock()
def __init__(self): # RawValue because we don't need it to create a Lock: self.val = RawValue('d', 0) self.num = RawValue('i', 0) self.lock = Lock()
import numpy as np import csv import pandas as pd import re import linecache import time import matplotlib.pyplot as plt import matplotlib from multiprocessing import Pool, sharedctypes, RawArray, RawValue from MS.IBIS import * from MS.LPJ import * from MS.Biome_BGC import * from CMIP import * plt.switch_backend('tkagg') counter = RawValue('i') counter.value = 0 failed_counter = RawValue('i') failed_counter.value = 0 test = False options, args = getopt.getopt(sys.argv[1:], '', ['model=', 'test=']) for opt in options: if (opt[0] == '--model'): if opt[1] == 'IBIS': ms_daily = IBIS('daily') ms_month = IBIS('month') elif opt[1] == 'Biome-BGC': ms_daily = Biome_BGC('daily') ms_month = Biome_BGC('month') elif opt[1] == 'LPJ': ms_daily = LPJ('daily')
def __init__(self): print("SimulationCommunicator object created") #wartosci-rezultaty dzialania symulacji self.ball_x = RawValue('f', 0.0) self.ball_y = RawValue('f', 0.0) self.servo_x = RawValue('i', 0) self.servo_y = RawValue('i', 0) self.corner_tl_x = RawValue('f', 0.0) self.corner_tl_y = RawValue('f', 0.0) self.corner_tr_x = RawValue('f', 0.0) self.corner_tr_y = RawValue('f', 0.0) self.corner_br_x = RawValue('f', 0.0) self.corner_br_y = RawValue('f', 0.0) self.corner_bl_x = RawValue('f', 0.0) self.corner_bl_y = RawValue('f', 0.0) self.cameraFrame = RawArray('i', 3 * 256**2) #zmienne wartosci self.servo_actual_pos = [0, 0] #aktualna pozycja serwa self.servo_target_pos = [0, 0] #docelowa pozycja serwa self.refreshDeltaTime = 1 / 60 self.frameReadTargetDelta = 1 / 40 self.frameReadLastTime = 0.0 self.capturedFrame = np.zeros((256, 256, 3))