Skip to content

Commit

Permalink
seda url, animation basemap, and harmonize to gdf
Browse files Browse the repository at this point in the history
  • Loading branch information
knaaptime committed Jan 16, 2024
1 parent 3a1cb0f commit 1d0169e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 5 additions & 1 deletion geosnap/_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,11 @@ def seda(
"gcs",
"cs",
], "`standardize` argument must be either 'cs' for cohort-standardized or 'gcs' for grade-cohort-standardized"
fn = f"seda_{level}_{pooling}_{standardize}_4.1"
if pooling=='poolsub':
fn = f"seda_{level}_{pooling}_{standardize}_4.1_corrected"
else:
fn = f"seda_{level}_{pooling}_{standardize}_4.1"

local_path = pathlib.Path(self.data_dir, "seda", f"{fn}.parquet")
remote_path = f"https://stacks.stanford.edu/file/druid:xv742vh9296/{fn}.csv"
msg = (
Expand Down
11 changes: 6 additions & 5 deletions geosnap/harmonize/harmonize.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def harmonize(
if intensive_variables is not None:
for i in intensive_variables:
allcols.append(i)

with tqdm(total=len(times), desc=f"Converting {len(times)} time periods") as pbar:
for i in times:
pbar.set_description(f"Harmonizing {i}")
Expand All @@ -172,10 +172,10 @@ def harmonize(
allocate_total=allocate_total,
)
else:
# if there are NaNs, tobler will raise lots of warnings, that it's filling
# with implicit 0s. Those warnings are superfluous most of the time
# if there are NaNs, tobler will raise lots of warnings, that it's filling
# with implicit 0s. Those warnings are superfluous most of the time
with warnings.catch_warnings():
warnings.simplefilter("ignore")
warnings.simplefilter("ignore")
interpolation = area_interpolate(
source_df,
target_df.copy(),
Expand Down Expand Up @@ -225,7 +225,8 @@ def harmonize(
pbar.update(1)
pbar.set_description("Complete")
pbar.close()
interpolated_dfs.append(target_df[allcols].set_index(unit_index))
if target_year is not None:
interpolated_dfs.append(target_df[allcols].set_index(unit_index))

harmonized_df = gpd.GeoDataFrame(pd.concat(interpolated_dfs), crs=crs)

Expand Down
3 changes: 3 additions & 0 deletions geosnap/visualize/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ def plot_timeseries(
axs.format(suptitle=column)
else:
axs.format(suptitle=title)
else:
if title:
plt.suptitle(title)

if save_fig:
f.savefig(save_fig, dpi=dpi, bbox_inches="tight")
Expand Down

0 comments on commit 1d0169e

Please sign in to comment.