コード例 #1
0
 def accept(self):
     with WaitCursorManager(
             'Extracting custom site ids...',
             message_bar=self.iface.messageBar()):
         log_msg('Extracting custom site ids', level='I',
                 print_to_stdout=True)
         sitecol = extract_npz(
             self.session, self.hostname, self.calc_id,
             'sitecol', message_bar=self.iface.messageBar())
         try:
             custom_site_ids = sitecol['array']['custom_site_id']
         except ValueError:
             custom_site_ids = sitecol['array']['sids']
             msg = ('Missing field "custom_site_id", needed by some '
                    'OQ-GeoViewer projects. Using "sids" instead.')
             log_msg(msg, level='W', print_to_stdout=True,
                     message_bar=self.iface.messageBar())
     with WaitCursorManager(
             'Creating disaggregation layer',
             self.iface.messageBar()):
         log_msg('Creating disagg_layer', level='I',
                 print_to_stdout=True)
         log_msg('Getting disagg array', level='I', print_to_stdout=True)
         disagg_array = self.disagg['array']
         lons = disagg_array['lon']
         lats = disagg_array['lat']
         self.layer = self.build_layer(
             self.disagg, disagg_array, lons, lats, custom_site_ids)
         if custom_site_ids is not None:
             self.build_custom_site_ids_layer(lons, lats, custom_site_ids)
         self.style_curves()
コード例 #2
0
    def __init__(self,
                 iface,
                 viewer_dock,
                 session,
                 hostname,
                 calc_id,
                 output_type='uhs',
                 path=None,
                 mode=None,
                 engine_version=None):
        assert output_type == 'uhs'
        LoadOutputAsLayerDialog.__init__(self,
                                         iface,
                                         viewer_dock,
                                         session,
                                         hostname,
                                         calc_id,
                                         output_type=output_type,
                                         path=path,
                                         mode=mode,
                                         engine_version=engine_version)

        self.setWindowTitle('Load uniform hazard spectra as layer')
        self.create_num_sites_indicator()
        self.create_load_selected_only_ckb()
        self.create_poe_selector()
        self.npz_file = extract_npz(session,
                                    hostname,
                                    calc_id,
                                    output_type,
                                    message_bar=iface.messageBar(),
                                    params=None)
        self.populate_out_dep_widgets()
        self.adjustSize()
        self.set_ok_button()
コード例 #3
0
 def extract_realizations(self):
     with WaitCursorManager('Extracting...',
                            message_bar=self.iface.messageBar()):
         self.rlzs_npz = extract_npz(self.session,
                                     self.hostname,
                                     self.calc_id,
                                     'realizations',
                                     message_bar=self.iface.messageBar(),
                                     params=None)
     self.rlzs_or_stats = [
         rlz_id for rlz_id in self.rlzs_npz['array']['rlz_id']
     ]
     self.gsims = [
         branch_path.decode('utf8').strip("\"")
         for branch_path in self.rlzs_npz['array']['branch_path']
     ]
コード例 #4
0
 def populate_rlz_or_stat_cbx(self):
     self.rlzs_or_stats = [
         key for key in sorted(self.npz_file)
         if key not in ('imtls', 'array')
     ]
     self.rlzs_npz = extract_npz(self.session,
                                 self.hostname,
                                 self.calc_id,
                                 'realizations',
                                 message_bar=self.iface.messageBar(),
                                 params=None)
     self.gsims = self.rlzs_npz['array']['gsims']
     self.rlz_or_stat_cbx.clear()
     self.rlz_or_stat_cbx.setEnabled(True)
     for gsim, rlz in zip(self.gsims, self.rlzs_or_stats):
         # storing gsim as text, rlz as hidden data
         self.rlz_or_stat_cbx.addItem(gsim, userData=rlz)
コード例 #5
0
    def __init__(self,
                 iface,
                 viewer_dock,
                 session,
                 hostname,
                 calc_id,
                 output_type='gmf_data',
                 path=None,
                 mode=None,
                 engine_version=None):
        assert output_type == 'gmf_data'
        LoadOutputAsLayerDialog.__init__(self,
                                         iface,
                                         viewer_dock,
                                         session,
                                         hostname,
                                         calc_id,
                                         output_type=output_type,
                                         path=path,
                                         mode=mode,
                                         engine_version=engine_version)

        self.setWindowTitle('Load ground motion fields from NPZ, as layer')
        self.create_load_selected_only_ckb()
        self.create_num_sites_indicator()
        # NOTE: gmpe and gsim are synonyms
        self.create_rlz_or_stat_selector('Ground Motion Prediction Equation')
        self.create_imt_selector()
        self.create_eid_selector()

        self.npz_file = extract_npz(session,
                                    hostname,
                                    calc_id,
                                    output_type,
                                    message_bar=iface.messageBar(),
                                    params=None)

        self.populate_out_dep_widgets()
        self.adjustSize()
        self.set_ok_button()
コード例 #6
0
    def __init__(self,
                 iface,
                 viewer_dock,
                 session,
                 hostname,
                 calc_id,
                 output_type=None,
                 path=None,
                 mode=None,
                 zonal_layer_path=None,
                 engine_version=None):
        assert output_type in ('losses_by_asset', 'avg_losses-stats')
        LoadOutputAsLayerDialog.__init__(self,
                                         iface,
                                         viewer_dock,
                                         session,
                                         hostname,
                                         calc_id,
                                         output_type=output_type,
                                         path=path,
                                         mode=mode,
                                         zonal_layer_path=zonal_layer_path,
                                         engine_version=engine_version)

        if self.output_type == 'losses_by_asset':
            self.setWindowTitle(
                'Load losses by asset, aggregated by location, as layer')
        elif self.output_type == 'avg_losses-stats':
            self.setWindowTitle('Load average asset losses (statistics),'
                                ' aggregated by location, as layer')
        else:
            raise NotImplementedError(output_type)
        self.create_load_selected_only_ckb()
        self.create_num_sites_indicator()
        self.create_rlz_or_stat_selector()
        self.create_taxonomy_selector()
        self.create_loss_type_selector()
        self.create_zonal_layer_selector()

        # NOTE: it's correct to use 'losses_by_asset' instead of output_type,
        #       both in case of losses_by_asset and in case of avg_losses-stats
        self.npz_file = extract_npz(session,
                                    hostname,
                                    calc_id,
                                    'losses_by_asset',
                                    message_bar=iface.messageBar(),
                                    params=None)

        self.loss_types = get_loss_types(session, hostname, calc_id,
                                         self.iface.messageBar())

        self.populate_out_dep_widgets()
        if self.zonal_layer_path:
            # NOTE: it happens while running tests. We need to avoid
            #       overwriting the original layer, so we make a copy of it.
            zonal_layer_plus_stats = self.load_zonal_layer(
                self.zonal_layer_path, make_a_copy=True)
            self.populate_zonal_layer_cbx(zonal_layer_plus_stats)
        else:
            self.pre_populate_zonal_layer_cbx()
        self.adjustSize()
        self.set_ok_button()