Skip to content

Commit

Permalink
revert to strict reqs
Browse files Browse the repository at this point in the history
  • Loading branch information
npucino committed Oct 9, 2021
1 parent 24dd6f7 commit 94e5ae3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 42 deletions.
23 changes: 13 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
geopandas
pandas
pysal
rasterio
richdem
scikit-image
scikit-learn
seaborn
tqdm
pooch
geopandas==0.8.2
matplotlib==3.3.4
numpy==1.20.1
pandas==1.2.2
pysal==2.1
rasterio==1.2.0
richdem==0.3.4
scikit-image==0.18.1
scikit-learn==0.24.1
scipy==1.6.0
seaborn==0.11.1
tqdm==4.56.2
pooch==1.4.0
fuzzywuzzy
40 changes: 20 additions & 20 deletions sandpyper/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@

from pysal.lib import weights

#import pysal.explore.esda.moran as moran
#from pysal.explore.esda.util import fdr
from esda import moran
from esda.util import fdr
import pysal.explore.esda.moran as moran
from pysal.explore.esda.util import fdr
#from esda import moran
#from esda.util import fdr

#from pysal.explore.giddy.markov import Markov
from giddy.markov import Markov
from pysal.explore.giddy.markov import Markov
#from giddy.markov import Markov

#from pysal.lib.weights import DistanceBand, Queen, higher_order
from libpysal.weights import DistanceBand, Queen, higher_order
from pysal.lib.weights import DistanceBand, Queen, higher_order
#from libpysal.weights import DistanceBand, Queen, higher_order

from pysal.viz.mapclassify import (EqualInterval,
FisherJenks,
Expand Down Expand Up @@ -1633,7 +1633,7 @@ def get_rbcd_transect(df_labelled, loc_specs, reliable_action, dirNameTrans, lab
).geometry

ss_transects_idx_loc = gpd.GeoDataFrame(
merged_erodepo, geometry="geometry", crs=CRS.from_epsg(crs_dict_string[loc]))
merged_erodepo, geometry="geometry", crs=crs_dict_string[loc] )

ss_transects_idx=pd.concat([ss_transects_idx_loc,ss_transects_idx], ignore_index=True)

Expand Down Expand Up @@ -2272,7 +2272,7 @@ def cleanit(to_clean, l_dicts, cluster_field='label_k', fill_class='sand',
selection=data_in[data_in.coordinates.intersects(row.geometry)]

if selection.shape[0]==0:
selection=data_in[data_in.to_crs(CRS.from_epsg(crs_dict_string[loc])).coordinates.intersects(row.geometry)]
selection=data_in[data_in.to_crs(crs_dict_string[loc] ).coordinates.intersects(row.geometry)]
else:
pass
selection["finetuned_label"]=new_class
Expand Down Expand Up @@ -2346,7 +2346,7 @@ def cleanit(to_clean, l_dicts, cluster_field='label_k', fill_class='sand',
selection=subset_data[subset_data.geometry.intersects(subset_masks.geometry)]
if selection.shape[0]==0:
print(f"Reprojecting")
selection=subset_data[subset_data.geometry.intersects(subset_masks.to_crs(CRS.from_epsg(crs_dict_string[loc])).geometry.any())]
selection=subset_data[subset_data.geometry.intersects(subset_masks.to_crs(crs_dict_string[loc]).geometry.any())]
else:
pass

Expand Down Expand Up @@ -2415,7 +2415,7 @@ def cleanit(to_clean, l_dicts, cluster_field='label_k', fill_class='sand',
if in_shore.shape[0]>=1:
pass
else:
in_shore=loc_selection[loc_selection.geometry.intersects(shore.to_crs(CRS.from_epsg(crs_dict_string[loc])).geometry.any())]
in_shore=loc_selection[loc_selection.geometry.intersects(shore.to_crs(crs_dict_string[loc]).geometry.any())]

print(f"Removing {loc_selection.shape[0] - in_shore.shape[0]} pts falling outside provided shore polygones.")
inshore_cleaned=pd.concat([in_shore,inshore_cleaned], ignore_index=True)
Expand Down Expand Up @@ -4198,7 +4198,7 @@ def error_from_gt(
Returns:
pd.DataFrame: Dataframe containing the distances from groundtruth at each timestep.
"""
crs = CRS.from_epsg(crs_dict_string[loc])
crs = crs_dict_string[loc]

if os.path.isfile(baseline_mode):
print("Fixed baseline mode selected.")
Expand Down Expand Up @@ -4530,7 +4530,7 @@ def tidal_correction(
gt_shores = cs_shores.query(
f"location=='{location}' & raw_date in @list_dates"
) # get groudtruths shores
crs = CRS.from_epsg(crs_dict_string[loc]) # get crs of location
crs = crs_dict_string[loc] # get crs of location

if shores_to_corr.crs != crs:
shores_to_corr = shores_to_corr.to_crs(crs)
Expand Down Expand Up @@ -5176,7 +5176,7 @@ def save_slope_corr_files(
print(f"Working on {location} .")
slope_file_name = f"slopeprofiles_{location}_{alongshore_resolution}_{tick_length}_{across_shore_resolution_txt}.csv"

crs = CRS.from_epsg(crs_dict_string[loc]) # get crs of location
crs = crs_dict_string[loc] # get crs of location

baseline_location_path = [
os.path.join(baseline_folder, baseline)
Expand Down Expand Up @@ -5559,7 +5559,7 @@ def tiles_from_grid(
"""

loc = getLoc(img_path, list_loc_codes)
crs = CRS.from_epsg(crs_dict_string[loc])
crs = crs_dict_string[loc]

if driver == "PNG":
ext = "png"
Expand Down Expand Up @@ -5621,7 +5621,7 @@ def tiles_from_grid(
width_idx = 2

# creates gereferenced bounding box of the image
geom_im = gpd.GeoSeries(box(*dataset.bounds), crs=CRS.from_epsg(crs_dict_string[loc]))
geom_im = gpd.GeoSeries(box(*dataset.bounds), crs=crs_dict_string[loc] )

# evaluates which tiles are fully within the raster bounds
fully_contains = [
Expand Down Expand Up @@ -5725,7 +5725,7 @@ def arr2geotiff(
count=array.shape[2],
dtype=dtype,
transform=transform,
crs=CRS.from_epsg(crs_dict_string[loc])
crs=crs_dict_string[loc]
)

mem_dataset.write(array.reshape((shape[0], shape[1])), indexes=shape[2])
Expand All @@ -5740,7 +5740,7 @@ def arr2geotiff(
count=array.shape[2],
dtype=dtype,
transform=transform,
crs=CRS.from_epsg(crs_dict_string[loc])
crs=crs_dict_string[loc]
) as dest:
if driver == "PNG":
dest.write(mem_dataset.astype(ras.uint16), indexes=1)
Expand Down Expand Up @@ -5841,7 +5841,7 @@ def LISA_site_level(
df_in = df.query(f"location=='{loc}'") # subset a location

# create a GeoDataFrame with the right CRS
gdf = gpd.GeoDataFrame(df_in, geometry=geometry_column, crs=CRS.from_epsg(crs_dict_string[loc]))
gdf = gpd.GeoDataFrame(df_in, geometry=geometry_column, crs=crs_dict_string[loc] )

dts = gdf.dt.unique() # obtain list of periods

Expand Down
4 changes: 2 additions & 2 deletions sandpyper/sandpyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import matplotlib.pyplot as plt
from itertools import product as prod

from giddy.markov import Markov
#from pysal.explore.giddy.markov import Markov
#from giddy.markov import Markov
from pysal.explore.giddy.markov import Markov

from pysal.viz.mapclassify import (EqualInterval,
FisherJenks,
Expand Down
16 changes: 6 additions & 10 deletions tests/test_sandpyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
import pickle
import numpy as np
import geopandas as gpd

from pyproj import CRS


import pandas as pd
import shapely
import sandpyper
Expand All @@ -32,7 +28,7 @@
'min_points':6}}

loc_search_dict = {'leo': ['St', 'Leonards', 'leonards', 'leo'], 'mar': ['Marengo', 'marengo', 'mar'] }
crs_dict_string = {'mar': 32754, 'leo':32755}
crs_dict_string = {'mar': {'init': 'epsg:32754'}, 'leo':{'init': 'epsg:32755'} }

labels=["Undefined", "Small", "Medium", "High", "Extreme"]

Expand Down Expand Up @@ -149,7 +145,7 @@ def test_000_CreateTransects(self):
sampling_step=20,
tick_length=50,
location='leo',
crs=CRS.from_epsg(crs_dict_string['leo']),
crs=crs_dict_string['leo'],
side='both'
)
self.assertEqual(transects_leo.shape, (59, 3))
Expand All @@ -163,7 +159,7 @@ def test_001_CreateTransects(self):
sampling_step=20,
tick_length=50,
location='mar',
crs=CRS.from_epsg(crs_dict_string['mar']),
crs=crs_dict_string['mar'],
side='both'
)

Expand All @@ -177,21 +173,21 @@ def test_002_CreateTransects(self):
create_transects(self.leo_shoreline,
sampling_step=0,
tick_length=100,
location='leo' ,crs=CRS.from_epsg(crs_dict_string['leo']),
location='leo' ,crs=crs_dict_string['leo'],
side='both'
)

def test_003_CreateTransects(self):
right=create_transects(self.mar_shoreline,
sampling_step=150,
tick_length=50,
location='mar' ,crs=CRS.from_epsg(crs_dict_string['mar']),
location='mar' ,crs=crs_dict_string['mar'],
side='right'
)
left=create_transects(self.mar_shoreline,
sampling_step=150,
tick_length=50,
location='mar' ,crs=CRS.from_epsg(crs_dict_string['mar']),
location='mar' ,crs=crs_dict_string['mar'],
side='left'
)
self.assertTrue(right.touches(left).all())
Expand Down

0 comments on commit 94e5ae3

Please sign in to comment.