示例#1
0
    def grow_landuse(land1, num_growth_pix):
        nrows = IGrid.nrows
        ncols = IGrid.ncols
        ticktock = Processing.get_current_year()
        landuse0_year = IGrid.igrid.get_landuse_year(0)
        landuse1_year = IGrid.igrid.get_landuse_year(1)
        urban_code = LandClass.get_urban_code()
        new_indices = LandClass.get_new_indices()
        landuse_classes = LandClass.get_landclasses()
        class_indices = LandClass.get_reduced_classes()
        background = IGrid.igrid.get_background()
        slope = IGrid.igrid.get_slope()
        deltatron = PGrid.get_deltatron()
        z = PGrid.get_z()
        land2 = PGrid.get_land2()
        class_slope = Transition.get_class_slope()
        ftransition = Transition.get_ftransition()

        if ticktock >= landuse0_year:
            # Place the New Urban Simulation into the Land Use Image
            Utilities.condition_gt_gif(z.gridData, 0, land1.gridData,
                                       urban_code)
            Deltatron.deltatron(new_indices, landuse_classes, class_indices,
                                deltatron, land1, land2, slope, num_growth_pix,
                                class_slope, ftransition)

            # Switch the old to the new
            for i in range(len(land2.gridData)):
                land1.gridData[i] = land2.gridData[i]

        if Processing.get_processing_type() == Globals.mode_enum['predict'] or \
            (Processing.get_processing_type() == Globals.mode_enum['test'] and
             Processing.get_current_monte() == Processing.get_last_monte()):
            #Write land1 to file
            if IGrid.using_gif:
                filename = f"{Scenario.get_scen_value('output_dir')}{IGrid.igrid.location}_land_n_urban" \
                           f".{Processing.get_current_year()}.gif"
            else:
                filename = f"{Scenario.get_scen_value('output_dir')}{IGrid.igrid.location}_land_n_urban" \
                           f".{Processing.get_current_year()}.tif"
                IGrid.echo_meta(
                    f"{Scenario.get_scen_value('output_dir')}{IGrid.igrid.location}_land_n_urban."
                    f"{Processing.get_current_year()}.tfw", "landuse")

            date = f"{Processing.get_current_year()}"
            ImageIO.write_gif(land1, Color.get_landuse_table(), filename, date,
                              nrows, ncols)

        # Compute final match statistics for landuse
        Utilities.condition_gt_gif(z.gridData, 0, land1.gridData, urban_code)