From bf101c8b182d62a68b02941eb976b395e0614006 Mon Sep 17 00:00:00 2001 From: Frederique Date: Fri, 8 Dec 2023 17:31:44 +0100 Subject: [PATCH] avoiding double downloading --- hydromt_fiat/workflows/equity_data.py | 9 ++++++--- hydromt_fiat/workflows/social_vulnerability_index.py | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/hydromt_fiat/workflows/equity_data.py b/hydromt_fiat/workflows/equity_data.py index 43fb1fa4..0439d1d7 100644 --- a/hydromt_fiat/workflows/equity_data.py +++ b/hydromt_fiat/workflows/equity_data.py @@ -52,10 +52,13 @@ def set_up_state_code(self, state_abbreviation: List[str]): state_abbreviation : str Abbreviation of the state for which you want to set up the census data download """ + states_done = [] for state in state_abbreviation: - self.logger.info(f"The state abbreviation specified is: {state}") - state_obj = getattr(states, state) - self.state_fips.append(state_obj.fips) + if state not in states_done: + self.logger.info(f"The state abbreviation specified is: {state}") + state_obj = getattr(states, state) + self.state_fips.append(state_obj.fips) + states_done.append(state) def variables_to_download(self): self.download_variables = ['B01003_001E', 'B19301_001E', 'NAME', 'GEO_ID'] # TODO: later make this a user input? diff --git a/hydromt_fiat/workflows/social_vulnerability_index.py b/hydromt_fiat/workflows/social_vulnerability_index.py index 94320879..31d1d62a 100644 --- a/hydromt_fiat/workflows/social_vulnerability_index.py +++ b/hydromt_fiat/workflows/social_vulnerability_index.py @@ -141,10 +141,13 @@ def set_up_state_code(self, state_abbreviation: List[str]): state_abbreviation : str Abbreviation of the state for which you want to set up the census data download """ + states_done = [] for state in state_abbreviation: - self.logger.info(f"The state abbreviation specified is: {state}") - state_obj = getattr(states, state) - self.state_fips.append(state_obj.fips) + if state not in states_done: + self.logger.info(f"The state abbreviation specified is: {state}") + state_obj = getattr(states, state) + self.state_fips.append(state_obj.fips) + states_done.append(state) def download_census_data(self, year_data):