def array_to_loc_list(station_array): """ Convert a :class:`numpy.ndarray` into a list of :class:`~polyadcirc.pyADCIRC.basic.location`. :param station_array: an array of shape (n, 2) where n is the number of station locations :type station_array: :class:`numpy.ndarray` :rtype: list :returns: list of :class:`~polyadcirc.pyADCIRC.basic.location` """ stations = [] for i in station_array: stations.append(basic.location(i[0], i[1])) return stations
def _read_record7(fid, key1, key2, line, data): """ Saves metadata to ``data.stations[key]`` and ``data.recording[key]`` that is used to preallocate arrays for data recording for ``fort.7#`` type ADCIRC output files :param fid: :class:``file`` object :param string key1: ADCIRC Output File Type sans ``.`` :param string key2: ADCIRC Output File Type sans ``.`` :param line: array of parameters read from ``fort.15`` file :type line: :class:``numpy.ndarray`` :param data: object to store mesh specific data :type data: :class:``~polyadcirc.run_framework.domain`` :rtype: string :returns: station type description """ nout, touts, toutf, nspool = np.fromstring(line[0].strip(), sep=' ') touts = max(touts, data.time.statim) toutf = min(toutf, data.time.rnday+data.time.statim) description = None if nout != 0 and nspool != 0: total_obs = int((toutf - touts) * 24.0 * 60 * 60 / data.time.dt/ nspool) else: total_obs = 0 if filetype[key1][0]: line = fid.readline().partition('!') meas_locs = int(line[0].strip()) stations = [] description = line[-1] for i in xrange(meas_locs): line = fid.readline() line = line.partition('!') line = re.findall(r"[-*\d\.\d]+", line[0].strip()) stations.append(basic.location(float(line[0]), float(line[-1]))) data.stations[key1] = stations data.stations[key2] = stations else: meas_locs = data.node_num data.recording[key1] = (meas_locs, total_obs, filetype[key1][1]) data.recording[key2] = (meas_locs, total_obs, filetype[key2][1]) return description
wall_points = np.column_stack((xmin, xmax, ymin, ymax, wall_height)) wall_points = wall_points.transpose() # setup and save to shelf # set up saving save_file = 'py_save_file' stat_x = np.concatenate((1900*np.ones((7,)), [1200], 1300*np.ones((3,)), [1500])) stat_y = np.array([1200, 600, 300, 0, -300, -600, -1200, 0, 1200, 0, -1200, -1400]) stations = [] for x, y in zip(stat_y, stat_y): stations.append(basic.location(x, y)) # Run experiments # MainFile_RandomMann main_run.run_nobatch_q(domain, wall_points, mann_pts, save_file, num_procs=nprocs, procs_pnode=ppnode, stations=stations, TpN=TpN)
xmin = 1420 xmax = 1580 ymax = 1500 wall_height = -2.5 param_min = lam_domain[:, 0] param_max = lam_domain[:, 1] # Create stations stat_x = np.concatenate((1900*np.ones((7,)), [1200], 1300*np.ones((3,)), [1500])) stat_y = np.array([1200, 600, 300, 0, -300, -600, -1200, 0, 1200, 0, -1200, -1400]) all_stations = [] for x, y in zip(stat_x, stat_y): all_stations.append(basic.location(x, y)) # Select only the stations I care about this will lead to better sampling station_nums = [0, 5] # 1, 6 stations = [] for s in station_nums: stations.append(all_stations[s]) # Create Transition Kernel transition_set = asam.transition_set(.5, .5**5, 1.0) # Read in Q_ref and Q to create the appropriate rho_D mdat = sio.loadmat('Q_2D') Q = mdat['Q'] Q = Q[:, station_nums] Q_ref = mdat['Q_true']