ecoscape-earth / ecoscape-layers

A tool for generating the species-specific input needed to run ecoscape (habitat, terrain and resistance map)
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Removed new refinement methods #14

Open lucadealfaro opened 3 weeks ago

lucadealfaro commented 3 weeks ago

I removed the following code:

                # check if in at least one of multiple habitat ranges
                def in_hab(*ranges: tuple[int, int]) -> bool:
                    return any((r[0] <= map_code < r[1]) for r in ranges)

                if h is not None:
                    if refine_method == "forest" or refine_method == "forest_add308":
                        h["resistance"] = 0 if in_hab(self.FORESTS) else h["resistance"]
                    elif refine_method == "forest_africa":
                        # will have the forest and shrublands set to 0 regardless of the habitat data
                        h["resistance"] = 0 if in_hab(self.FORESTS, self.SHRUBLANDS) else h["resistance"]

                    writer.writerow(h.values())
                else:
                    if refine_method == "forest" or refine_method == "forest_add308":
                        writer.writerow([""] * 5 + [map_code] + [0 if in_hab(self.FORESTS) else 1])
                    elif refine_method == "forest_africa":
                        resistance = 1
                        if in_hab(self.FORESTS, self.SHRUBLANDS):
                            resistance = 0
                        elif in_hab(self.INTRODUCED_VEGETATION):
                            resistance = 0.1
                        elif in_hab(
                            self.SAVANNAS,
                            self.GRASSLANDS,
                            self.WETLANDS,
                            self.ROCKY,
                            self.CAVES,
                            self.OTHER,
                            self.UNKNOWN,
                        ):
                            resistance = 0.9
                        elif in_hab(
                            self.DESERTS,
                            self.MARINE_NERITIC,
                            self.MARINE_OCEANIC,
                            self.MARINE_DEEP,
                            self.MARINE_INTERTIDAL,
                            self.MARINE_COSTAL,
                            self.ARTIFICIAL,
                        ):
                            resistance = 1

I have the following issues with it.

As an example of the second point, it's not reasonable to add a forest_africa method -- the africa work should post-process the csv any way they want for resistance.

Rather, this package should be mainly concerned with getting the habitat raster right.

IanHollow commented 1 week ago

@lucadealfaro

Let me know what your thoughts are and I will take appropriate action.