Skip to content

Commit

Permalink
clean up and correction output
Browse files Browse the repository at this point in the history
  • Loading branch information
Marie Laurent committed Jul 29, 2024
1 parent 30709d3 commit fdf37e9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 2 additions & 0 deletions data/hts/entd/cleaned.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ def execute(context):

# Socioprofessional class
df_persons["socioprofessional_class"] = df_persons["CS24"].fillna(80).astype(int) // 10

hts.fix_activity_types(df_trips)

return df_households, df_persons, df_trips

Expand Down
13 changes: 5 additions & 8 deletions data/hts/entd/filtered.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ def configure(context):
context.stage("data.hts.entd.cleaned")
context.stage("data.spatial.codes")

context.config("filter_entd", False)
context.config("filter_hts", True)

def execute(context):
filter_entd = context.config("filter_entd")
filter_entd = context.config("filter_hts")
df_codes = context.stage("data.spatial.codes")
df_households, df_persons, df_trips = context.stage("data.hts.entd.cleaned")

Expand All @@ -31,13 +31,10 @@ def execute(context):
]["person_id"].unique())

df_persons = df_persons[~df_persons["person_id"].isin(remove_ids)]

else:
df_persons = df_persons[~df_persons["person_id"].isin([34581])] # remove persons leading to activity types error

# Only keep trips and households that still have a person
df_trips = df_trips[df_trips["person_id"].isin(df_persons["person_id"].unique())]
df_households = df_households[df_households["household_id"].isin(df_persons["household_id"])]
# Only keep trips and households that still have a person
df_trips = df_trips[df_trips["person_id"].isin(df_persons["person_id"].unique())]
df_households = df_households[df_households["household_id"].isin(df_persons["household_id"])]

# Finish up
df_households = df_households[hts.HOUSEHOLD_COLUMNS + ["urban_type", "income_class"]]
Expand Down
2 changes: 1 addition & 1 deletion data/od/weighted.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
def configure(context):
context.stage("data.od.cleaned")
context.stage("data.spatial.codes")
context.config("output_path")

context.config("education_location_source","bpe")

def fix_origins(df, commune_ids, purpose,category):
Expand Down
7 changes: 4 additions & 3 deletions documentation/flow_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def execute(context):
"Yrs:75+":{"min_age": 76, "max_age": 110,},}

if not context.config("analysis_from_file"):
print("Récupération simu données ...")
# from simulation cache
df_trips = context.stage("synthesis.population.trips")
df_persons = context.stage("synthesis.population.enriched")[["person_id", "household_id","age"]]
Expand Down Expand Up @@ -84,7 +85,6 @@ def execute(context):
for prefix, figure in figures.items():
df_select_age = df_stats[df_stats["age"].between(figure["min_age"],figure["max_age"])]
df_select_age = df_select_age.dissolve(by=["id_carr_1km","following_purpose"],aggfunc="count").reset_index()
print(prefix)
df_select_age = df_select_age[~(df_select_age["geometry"].isna())]
df_select_age["following_purpose"] = df_select_age["following_purpose"].astype('str')

Expand All @@ -101,8 +101,9 @@ def execute(context):
df_tiles_select = gpd.sjoin(df_tiles_select,df_tile,how='right',predicate="contains").fillna(0)
df_select = gpd.sjoin(df_select.drop(columns=['index_right']),df_tiles_select.drop(columns=[ 'index_left']),how='right',predicate="contains").rename(columns={"count_left":"volume_studied_simu","count_right":"volume_compared_simu"}).fillna(0)
df_select["volume_difference"] = df_select["volume_studied_simu"] - df_select["volume_compared_simu"]
#df_select = df_select[df_select["volume_difference"] != 0]
px.choropleth_mapbox(df_select,geojson=df_select.geometry,locations=df_select.index,color="volume_difference", opacity= 0.7,color_continuous_scale="picnic", color_continuous_midpoint= 0,hover_name="id_carr_1km_right", hover_data=["volume_studied_simu", "volume_compared_simu"],
df_select = df_select[(df_select["volume_studied_simu"] != 0 )| (df_select["volume_compared_simu"] != 0)]
df_select["pourcentage_vol"] = df_select["volume_difference"] / df_select["volume_compared_simu"]
px.choropleth_mapbox(df_select,geojson=df_select.geometry,locations=df_select.index,color="volume_difference", opacity= 0.7,color_continuous_scale="picnic", color_continuous_midpoint= 0,hover_name="id_carr_1km_right", hover_data=["volume_studied_simu", "volume_compared_simu","pourcentage_vol"],
mapbox_style = 'open-street-map',center=dict(lat= point.y,lon=point.x),title=f"Comparison flow distribution with previous simulation for {prefix} group with {purpose} purpose").write_html(f'{context.config("output_path")}/{context.config("output_prefix")}{prefix}_{purpose}.html')


2 changes: 1 addition & 1 deletion synthesis/population/spatial/primary/candidates.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def configure(context):
context.stage("synthesis.population.spatial.home.zones")
context.stage("synthesis.population.enriched")
context.stage("synthesis.population.trips")
context.config("output_path")

context.config("random_seed")
context.config("education_location_source", "bpe")

Expand Down

0 comments on commit fdf37e9

Please sign in to comment.