Ejemplo n.º 1
0
    def __init__(self, state, parameters, config, timeseries):
        """
        Initialize a company to manage the fixed crews (e.g. a contracting company).

        """
        self.name = 'fixed'
        self.state = state
        self.parameters = parameters
        self.config = config
        self.timeseries = timeseries
        self.crews = []
        self.deployment_days = self.state['weather'].deployment_days('fixed')
        self.timeseries['fixed_prop_sites_avail'] = []
        self.timeseries['fixed_cost'] = np.zeros(self.parameters['timesteps'])
        self.timeseries['fixed_eff_flags'] = np.zeros(
            self.parameters['timesteps'])
        self.timeseries['fixed_flags_redund1'] = np.zeros(
            self.parameters['timesteps'])
        self.timeseries['fixed_flags_redund2'] = np.zeros(
            self.parameters['timesteps'])
        self.timeseries['fixed_flags_redund3'] = np.zeros(
            self.parameters['timesteps'])

        # Assign the correct follow-up threshold
        if self.config['follow_up_thresh'][1] == "absolute":
            self.config['follow_up_thresh'] = self.config['follow_up_thresh'][
                0]
        elif self.config['follow_up_thresh'][1] == "proportion":
            self.config['follow_up_thresh'] = get_prop_rate(
                self.config['follow_up_thresh'][0],
                self.state['empirical_leaks'])
        else:
            print(
                'Follow-up threshold type not recognized. Must be "absolute" or "proportion".'
            )

        # Initialize 2D matrices to store deployment day (DD) counts and MCBs
        self.DD_map = np.zeros((len(self.state['weather'].longitude),
                                len(self.state['weather'].latitude)))
        self.MCB_map = np.zeros((len(self.state['weather'].longitude),
                                 len(self.state['weather'].latitude)))

        # Initialize the individual fixed crews (the agents) - each is a single fixed sensor
        for site in self.state['sites']:
            n_fixed = int(site['fixed_sensors'])
            for i in range(n_fixed):
                self.crews.append(
                    fixed_crew(state,
                               parameters,
                               config,
                               timeseries,
                               site,
                               self.deployment_days,
                               id=site['facility_ID'] + '-' + str(i + 1)))
                self.timeseries['fixed_cost'][self.state['t'].current_timestep] += \
                    self.parameters['methods']['fixed']['up_front_cost']

        return
Ejemplo n.º 2
0
    def __init__(self, state, parameters, config, timeseries):
        """
        Initialize a company to manage the aircraft crews (e.g. a contracting company).

        """
        self.name = 'aircraft'
        self.state = state
        self.parameters = parameters
        self.config = config
        self.timeseries = timeseries
        self.crews = []
        self.deployment_days = self.state['weather'].deployment_days('aircraft')
        self.timeseries['aircraft_prop_sites_avail'] = []
        self.timeseries['aircraft_cost'] = np.zeros(self.parameters['timesteps'])
        self.timeseries['aircraft_eff_flags'] = np.zeros(self.parameters['timesteps'])
        self.timeseries['aircraft_flags_redund1'] = np.zeros(self.parameters['timesteps'])
        self.timeseries['aircraft_flags_redund2'] = np.zeros(self.parameters['timesteps'])
        self.timeseries['aircraft_flags_redund3'] = np.zeros(self.parameters['timesteps'])
        self.timeseries['aircraft_sites_visited'] = np.zeros(self.parameters['timesteps'])

        # Assign the correct follow-up threshold
        if self.config['follow_up_thresh'][1] == "absolute":
            self.config['follow_up_thresh'] = self.config['follow_up_thresh'][0]
        elif self.config['follow_up_thresh'][1] == "proportion":
            self.config['follow_up_thresh'] = get_prop_rate(
                self.config['follow_up_thresh'][0],
                self.state['empirical_leaks'])
        else:
            print('Follow-up threshold type not recognized. Must be "absolute" or "proportion".')

        # Additional variable(s) for each site
        for site in self.state['sites']:
            site.update({'aircraft_t_since_last_LDAR': 0})
            site.update({'aircraft_surveys_conducted': 0})
            site.update({'attempted_today_aircraft?': False})
            site.update({'surveys_done_this_year_aircraft': 0})
            site.update({'aircraft_missed_leaks': 0})

        # Initialize 2D matrices to store deployment day (DD) counts and MCBs
        self.DD_map = np.zeros(
            (len(self.state['weather'].longitude),
             len(self.state['weather'].latitude)))
        self.MCB_map = np.zeros(
            (len(self.state['weather'].longitude),
             len(self.state['weather'].latitude)))

        # Initialize the individual aircraft crews (the agents)
        for i in range(config['n_crews']):
            self.crews.append(aircraft_crew(state, parameters, config,
                                            timeseries, self.deployment_days, id=i + 1))

        return
Ejemplo n.º 3
0
    def __init__(self, state, parameters, config, timeseries):
        """
        Initialize a company to manage the satellite
        """
        self.name = 'satellite'
        self.state = state
        self.parameters = parameters
        self.config = config
        self.timeseries = timeseries
        self.crews = []
        self.deployment_days = self.state['weather'].deployment_days('satellite')
        self.timeseries['satellite_prop_sites_avail'] = []
        self.timeseries['satellite_cost'] = np.zeros(self.parameters['timesteps'])
        self.timeseries['satellite_eff_flags'] = np.zeros(self.parameters['timesteps'])
        self.timeseries['satellite_flags_redund1'] = np.zeros(self.parameters['timesteps'])
        self.timeseries['satellite_flags_redund2'] = np.zeros(self.parameters['timesteps'])
        self.timeseries['satellite_flags_redund3'] = np.zeros(self.parameters['timesteps'])
        self.timeseries['satellite_sites_visited'] = np.zeros(self.parameters['timesteps'])

		# load pre-defined orbit grids
        Dataset = nc.Dataset(self.parameters['methods']['Satellite']['Satellite_grid'], 'r')
        self.satgrid = Dataset.variables['sat'][:]
        Dataset.close()

        # load cloud cover data
        Dataset = nc.Dataset(self.parameters['methods']['Satellite']['CloudCover'], 'r')
        self.cloudcover = Dataset.variables['tcc'][:]
        Dataset.close()

        # build a satellite orbit object
        sat = self.parameters['methods']['Satellite']['name']
        tlefile = self.parameters['methods']['Satellite']['TLE_file']
        TLEs = []
        with open(tlefile) as f:
            for line in f:
                TLEs.append(line.rstrip())

        i = 0
        for x in TLEs:
            if x == sat:
                break
            i += 1
        TLE_LINES = (TLEs[i+1], TLEs[i+2])

        self.predictor = get_predictor_from_tle_lines(TLE_LINES)

        return

        # Assign the correct follow-up threshold
        if self.config['follow_up_thresh'][1] == "absolute":
            self.config['follow_up_thresh'] = self.config['follow_up_thresh'][0]
        elif self.config['follow_up_thresh'][1] == "proportion":
            self.config['follow_up_thresh'] = get_prop_rate(
                self.config['follow_up_thresh'][0],
                self.state['empirical_leaks'])
        else:
            print('Follow-up threshold type not recognized. Must be "absolute" or "proportion".')

        # Additional variable(s) for each site
        for site in self.state['sites']:
            site.update({'satellite_t_since_last_LDAR': 0})
            site.update({'satellite_surveys_conducted': 0})
            site.update({'attempted_today_satellite?': False})
            site.update({'surveys_done_this_year_satellite': 0})
            site.update({'satellite_missed_leaks': 0})

        # Initialize 2D matrices to store deployment day (DD) counts and MCBs
        self.DD_map = np.zeros(
            (len(self.state['weather'].longitude),
              len(self.state['weather'].latitude)))
        self.MCB_map = np.zeros(
            (len(self.state['weather'].longitude),
              len(self.state['weather'].latitude)))