Пример #1
0
def test_draw_model():
    m = swmmio.Model(MODEL_FULL_FEATURES_XY)
    target_img_pth = os.path.join(DATA_PATH, 'test-draw-model.png')
    sg.draw_model(m, file_path=target_img_pth)

    assert os.path.exists(target_img_pth)
    os.remove(target_img_pth)
Пример #2
0
    def generate_figures(self, rpt_dir, parcel_shp_df, bbox=d68d70):

        basemodel = self.baseline_report.model
        altmodel = self.alt_report.model
        files = '{}\n{}'.format(basemodel.inp.path, altmodel.inp.path)


        #SIMPLE PLAN VIEW OF OPTION (showing new conduits)
        conduits = altmodel.conduits()
        pth = os.path.join(rpt_dir, '00 Proposed Infrastructure.png')
        conduits['draw_color'] = '#bebeb4' #default color
        conduits['draw_size'] = conduits.Geom1
        conduits.loc[self.new_ix, 'draw_color'] = '#1414e6' #new cond col
        conduits.loc[self.new_ix,'draw_size'] = conduits.loc[self.new_ix,'Geom1']*2
        sg.draw_model(conduits=conduits, nodes=altmodel.nodes(), bbox=bbox,
                      title=self.name, annotation=files, file_path=pth)

        #EXISTING CONDITIONS PARCEL FLOOD DURATION
        pth = os.path.join(rpt_dir, '01 Existing Parcel Flood Duration.png')
        base_conduits = basemodel.conduits()
        base_conduits['draw_color'] = '#bebeb4' #default color
        base_conduits['draw_size'] = base_conduits.Geom1
        pars = self.baseline_report.parcel_flooding
        pars = pd.merge(pars, parcel_shp_df, right_on='PARCELID', left_index=True)
        comp_cols = pars.apply(lambda row: drawing.parcel_draw_color(row, 'risk'), axis=1)
        pars = pars.assign(draw_color=comp_cols)
        sg.draw_model(conduits=base_conduits, nodes=basemodel.nodes(), parcels=pars,
                      bbox=bbox,title=self.name, annotation=self.baseline_report.__str__(),
                      file_path=pth)

        #PROPOSED CONDITIONS PARCEL FLOOD DURATION
        pth = os.path.join(rpt_dir, '02 Proposed Parcel Flood Duration.png')
        pars = self.alt_report.parcel_flooding
        pars = pd.merge(pars, parcel_shp_df, right_on='PARCELID', left_index=True)
        comp_cols = pars.apply(lambda row: drawing.parcel_draw_color(row, 'risk'), axis=1)
        pars = pars.assign(draw_color=comp_cols)
        sg.draw_model(conduits=conduits, nodes=altmodel.nodes(), parcels=pars,
                      bbox=bbox,title=self.name, annotation=self.alt_report.__str__(),
                      file_path=pth)

        #IMPACT OF INFRASTRUCTURE
        pth = os.path.join(rpt_dir, '03 Impact of Option.png')
        pars = pd.merge(self.flood_comparison, parcel_shp_df, right_on='PARCELID', left_index=True)
        comp_cols = pars.apply(lambda row: drawing.parcel_draw_color(row, 'delta'), axis=1)
        pars = pars.assign(draw_color=comp_cols)
        annotation = self.alt_report.__str__() + '\n\n' + self.__str__()
        sg.draw_model(conduits=conduits, nodes=altmodel.nodes(), parcels=pars,
                      bbox=bbox,title=self.name, annotation=annotation,
                      file_path=pth)

        #IMPACT OF INFRASTRUCTURE OVERALL
        pth = os.path.join(rpt_dir, '04 Impact of Option - Overall.png')
        sg.draw_model(conduits=conduits, nodes=altmodel.nodes(), parcels=pars,
                      bbox=study_area,title=self.name, annotation=annotation,
                      file_path=pth)
Пример #3
0
    def generate_figures(self, rpt_dir, parcel_shp_df, bbox=d68d70):

        basemodel = self.baseline_report.model
        altmodel = self.alt_report.model
        files = '{}\n{}'.format(basemodel.inp.path, altmodel.inp.path)


        #SIMPLE PLAN VIEW OF OPTION (showing new conduits)
        conduits = altmodel.conduits()
        pth = os.path.join(rpt_dir, '00 Proposed Infrastructure.png')
        conduits['draw_color'] = '#bebeb4' #default color
        conduits['draw_size'] = conduits.Geom1
        conduits.loc[self.new_ix, 'draw_color'] = '#1414e6' #new cond col
        conduits.loc[self.new_ix,'draw_size'] = conduits.loc[self.new_ix,'Geom1']*2
        sg.draw_model(conduits=conduits, nodes=altmodel.nodes(), bbox=bbox,
                      title=self.name, annotation=files, file_path=pth)

        #EXISTING CONDITIONS PARCEL FLOOD DURATION
        pth = os.path.join(rpt_dir, '01 Existing Parcel Flood Duration.png')
        base_conduits = basemodel.conduits()
        base_conduits['draw_color'] = '#bebeb4' #default color
        base_conduits['draw_size'] = base_conduits.Geom1
        pars = self.baseline_report.parcel_flooding
        pars = pd.merge(pars, parcel_shp_df, right_on='PARCELID', left_index=True)
        comp_cols = pars.apply(lambda row: drawing.parcel_draw_color(row, 'risk'), axis=1)
        pars = pars.assign(draw_color=comp_cols)
        sg.draw_model(conduits=base_conduits, nodes=basemodel.nodes(), parcels=pars,
                      bbox=bbox,title=self.name, annotation=self.baseline_report.__str__(),
                      file_path=pth)

        #PROPOSED CONDITIONS PARCEL FLOOD DURATION
        pth = os.path.join(rpt_dir, '02 Proposed Parcel Flood Duration.png')
        pars = self.alt_report.parcel_flooding
        pars = pd.merge(pars, parcel_shp_df, right_on='PARCELID', left_index=True)
        comp_cols = pars.apply(lambda row: drawing.parcel_draw_color(row, 'risk'), axis=1)
        pars = pars.assign(draw_color=comp_cols)
        sg.draw_model(conduits=conduits, nodes=altmodel.nodes(), parcels=pars,
                      bbox=bbox,title=self.name, annotation=self.alt_report.__str__(),
                      file_path=pth)

        #IMPACT OF INFRASTRUCTURE
        pth = os.path.join(rpt_dir, '03 Impact of Option.png')
        pars = pd.merge(self.flood_comparison, parcel_shp_df, right_on='PARCELID', left_index=True)
        comp_cols = pars.apply(lambda row: drawing.parcel_draw_color(row, 'delta'), axis=1)
        pars = pars.assign(draw_color=comp_cols)
        annotation = self.alt_report.__str__() + '\n\n' + self.__str__()
        sg.draw_model(conduits=conduits, nodes=altmodel.nodes(), parcels=pars,
                      bbox=bbox,title=self.name, annotation=annotation,
                      file_path=pth)

        #IMPACT OF INFRASTRUCTURE OVERALL
        pth = os.path.join(rpt_dir, '04 Impact of Option - Overall.png')
        sg.draw_model(conduits=conduits, nodes=altmodel.nodes(), parcels=pars,
                      bbox=study_area,title=self.name, annotation=annotation,
                      file_path=pth)
Пример #4
0
def test_draw_red_and_grey_nodes():
    m = swmmio.Model(MODEL_FULL_FEATURES__NET_PATH)
    target_img_pth = os.path.join(DATA_PATH, 'test-draw-model.png')
    nodes = m.nodes()
    nodes['draw_color'] = '#787882'
    nodes.loc[['J1', 'J2', 'J3'], 'draw_color'] = '#ff0000'
    nodes['draw_size'] = nodes['InvertElev'] * 3

    sg.draw_model(conduits=m.conduits(), nodes=nodes, file_path=target_img_pth)
    assert os.path.exists(target_img_pth)
    os.remove(target_img_pth)