From da075aa549e8aa3c5949bbada6d9a037031d13b8 Mon Sep 17 00:00:00 2001 From: Kevin Schwarzwald Date: Tue, 1 Oct 2024 12:08:42 +0200 Subject: [PATCH] Revert "Add CITATION.cff file" This reverts commit 78864ce7e1de3b2c885b554d97022145b4ab5f47. --- CITATION.cff | 13 ------------- tests/test_wrappers.py | 23 ----------------------- xagg/core.py | 2 -- xagg/wrappers.py | 23 ----------------------- 4 files changed, 61 deletions(-) delete mode 100644 CITATION.cff diff --git a/CITATION.cff b/CITATION.cff deleted file mode 100644 index 08cda2e..0000000 --- a/CITATION.cff +++ /dev/null @@ -1,13 +0,0 @@ -cff-version: 1.0 -message: "If you use this software, please cite it as below." -authors: -- family-names: "Schwarzwald" - given-names: "Kevin" - orcid: "https://orcid.org/0000-0001-8309-7124" -- family-names: "Geil" - given-names: "Kerrie" -title: "xagg: A Python package to aggregate gridded data onto polygons" -version: 0.3.2.3 -doi: https://zenodo.org/doi/10.5281/zenodo.11476311 -date-released: 2024-08-10 -url: "https://github.com/ks905383/xagg" \ No newline at end of file diff --git a/tests/test_wrappers.py b/tests/test_wrappers.py index fc0142b..f0360a2 100644 --- a/tests/test_wrappers.py +++ b/tests/test_wrappers.py @@ -140,26 +140,3 @@ def test_pixel_overlaps_silent_false(mock_stdout): # Check that nothing was printed assert mock_stdout.getvalue() != '' - -##### pixel_overlaps() CRS tests ##### -def test_pixel_overlaps_altcrs(): - # Test to make sure pixel_overlaps standardizes crs'es before - # calling `create_raster_polygons` and `get_pixel_overlaps` - ds = xr.Dataset({'test':(['lon','lat','time'],np.reshape(np.arange(1,28),(3,3,3))), - 'lat_bnds':(['lat','bnds'],np.array([[-1.5,-0.5],[-0.5,0.5],[0.5,1.5]])), - 'lon_bnds':(['lon','bnds'],np.array([[-1.5,-0.5],[-0.5,0.5],[0.5,1.5]]))}, - coords={'lat':(['lat'],np.array([-1,0,1])), - 'lon':(['lon'],np.array([-1,0,1])), - 'bnds':(['bnds'],np.array([0,1])), - 'time':(['time'],pd.date_range('2019-01-01','2019-01-03'))}) - - - # Create polygon covering multiple pixels - gdf = {'name':['test'], - 'geometry':[Polygon([(0,0),(0,1),(1,1),(1,0),(0,0)])]} - gdf = gpd.GeoDataFrame(gdf,crs="EPSG:4326") - - try: - pix_agg = pixel_overlaps(ds,gdf.to_crs('EPSG:26916')) - except Exception as e: - pytest.fail(f"Exception raised: {e}") diff --git a/xagg/core.py b/xagg/core.py index 5b20a1f..be8ab53 100644 --- a/xagg/core.py +++ b/xagg/core.py @@ -296,8 +296,6 @@ def create_raster_polygons(ds, # Subset by shapefile bounding box, if desired if subset_bbox is not None: if type(subset_bbox) == gpd.geodataframe.GeoDataFrame: - # Change to 4326 first, which is implicitly what ds is in - subset_bbox = subset_bbox.to_crs('EPSG:4326') # Using the biggest difference in lat/lon to make sure that the pixels are subset # in a way that the bounding box is fully filled out # bbox_thresh = np.max([ds.lat.diff('lat').max(),ds.lon.diff('lon').max()])+0.1 diff --git a/xagg/wrappers.py b/xagg/wrappers.py index 2ab8a13..494ce17 100644 --- a/xagg/wrappers.py +++ b/xagg/wrappers.py @@ -1,6 +1,5 @@ import warnings import xarray as xr -import numpy as np import copy from . core import (create_raster_polygons,get_pixel_overlaps) @@ -76,24 +75,6 @@ def pixel_overlaps(ds,gdf_in, # get modified gdf_in = copy.deepcopy(gdf_in) - # Choose a common crs for both, just to minimize the chance - # of geographic shenanigans - # (using the EASE grid https://nsidc.org/data/ease) - if np.all(gdf_in.total_bounds[[1,3]]>0): - # If min/max lat are both in NH, use North grid - #epsg_set = {'init':'EPSG:6931'} (change to below bc of depreciation of {'init':...} format in geopandas) - epsg_set = 'EPSG:6931' - elif np.all(gdf_in.total_bounds[[1,3]]<0): - # If min/max lat are both in SH, use South grid - #epsg_set = {'init':'EPSG:6932'} - epsg_set = 'EPSG:6932' - else: - # Otherwise, use the global/temperate grid - #epsg_set = {'init':'EPSG:6933'} - epsg_set = 'EPSG:6933' - # Set CRS - gdf_in = gdf_in.to_crs(epsg_set) - # Turn into dataset if dataarray if type(ds)==xr.core.dataarray.DataArray: if ds.name is None: @@ -111,10 +92,6 @@ def pixel_overlaps(ds,gdf_in, warnings.warning('Bounding box around polygon(s) from `gdf_in` includes no grid cells in `ds`...') else: pix_agg = create_raster_polygons(ds,subset_bbox=None,weights=weights,silent=silent) - - - # Ensure pix_agg is also set to the default CRS - pix_agg['gdf_pixels'] = pix_agg['gdf_pixels'].to_crs(epsg_set) # Get overlaps between these pixel polygons and the gdf_in polygons if not silent: