ThGaskin commited on
Commit
ab70c85
·
verified ·
1 Parent(s): 9fc0140

Upload Data/__init__.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. Data/__init__.py +6 -5
Data/__init__.py CHANGED
@@ -1,5 +1,10 @@
1
- import pandas as pd
 
2
  import os
 
 
 
 
3
 
4
  # We make relevant datasets contained in this folder available across the project, for easier integration and plotting.
5
  # The base directory points to the folder containing this file:
@@ -14,7 +19,6 @@ countries_by_region['Middle East'] = countries_by_region.pop('Western Asia')
14
  countries_by_region['South Asia'] = countries_by_region.pop('Southern Asia')
15
 
16
  # Make the world shapefile available for plotting
17
- import geopandas as gpd
18
  world = gpd.read_file(os.path.join(base_dir, "world_shapefile/ne_50m_admin_0_countries.shp"))
19
  world.to_crs("EPSG:3857", inplace=True) # Mercator projection by default
20
 
@@ -24,8 +28,6 @@ coordinates = dict((k, (coordinates['Latitude'][k], coordinates['Longitude'][k])
24
 
25
  # Load the various comparison datasets into a dictionary for easy plotting, assigning consistent colours
26
  # and markers for each.
27
- from Plots.colors import colors
28
- import xarray as xr
29
  flow_dsets = {
30
  "Quantmig": dict(
31
  data=xr.open_dataset(os.path.join(base_dir, "Flow_data/QuantMig_data/Quantmig_flows.nc")),
@@ -58,7 +60,6 @@ NatStat_net_migration = xr.open_dataarray(os.path.join(base_dir, "Net_migration/
58
  WPP_data = xr.open_dataset(os.path.join(base_dir, "UN_WPP_data/UN_WPP_data.nc"))
59
 
60
  # Calculate the fraction of population alive at start of 1990 in each destination country still alive at start of year
61
- import numpy as np
62
  gamma = (1-death_rate.sel({"Year": range(1989, 2024)})).assign_coords({"Year": np.arange(1990, 2025, 1)}).rename({
63
  "Country ISO": "Destination ISO"})
64
  gamma.loc[{"Year": 1990}] = 1.0
 
1
+ import geopandas as gpd
2
+ import numpy as np
3
  import os
4
+ import pandas as pd
5
+ import xarray as xr
6
+
7
+ from Plots.colors import colors
8
 
9
  # We make relevant datasets contained in this folder available across the project, for easier integration and plotting.
10
  # The base directory points to the folder containing this file:
 
19
  countries_by_region['South Asia'] = countries_by_region.pop('Southern Asia')
20
 
21
  # Make the world shapefile available for plotting
 
22
  world = gpd.read_file(os.path.join(base_dir, "world_shapefile/ne_50m_admin_0_countries.shp"))
23
  world.to_crs("EPSG:3857", inplace=True) # Mercator projection by default
24
 
 
28
 
29
  # Load the various comparison datasets into a dictionary for easy plotting, assigning consistent colours
30
  # and markers for each.
 
 
31
  flow_dsets = {
32
  "Quantmig": dict(
33
  data=xr.open_dataset(os.path.join(base_dir, "Flow_data/QuantMig_data/Quantmig_flows.nc")),
 
60
  WPP_data = xr.open_dataset(os.path.join(base_dir, "UN_WPP_data/UN_WPP_data.nc"))
61
 
62
  # Calculate the fraction of population alive at start of 1990 in each destination country still alive at start of year
 
63
  gamma = (1-death_rate.sel({"Year": range(1989, 2024)})).assign_coords({"Year": np.arange(1990, 2025, 1)}).rename({
64
  "Country ISO": "Destination ISO"})
65
  gamma.loc[{"Year": 1990}] = 1.0