diff --git a/LICENSE b/LICENSE index d7f789c..3205f2b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2025 SyncroSim +Copyright (c) 2026 SyncroSim Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/docs/_autosummary/pysyncrosim.raster.Raster.__init__.rst b/docs/_autosummary/pysyncrosim.raster.Raster.__init__.rst deleted file mode 100644 index e59201e..0000000 --- a/docs/_autosummary/pysyncrosim.raster.Raster.__init__.rst +++ /dev/null @@ -1,6 +0,0 @@ -pysyncrosim.raster.Raster.\_\_init\_\_ -====================================== - -.. currentmodule:: pysyncrosim.raster - -.. automethod:: Raster.__init__ \ No newline at end of file diff --git a/docs/_autosummary/pysyncrosim.raster.Raster.crs.rst b/docs/_autosummary/pysyncrosim.raster.Raster.crs.rst deleted file mode 100644 index 6f125c4..0000000 --- a/docs/_autosummary/pysyncrosim.raster.Raster.crs.rst +++ /dev/null @@ -1,6 +0,0 @@ -pysyncrosim.raster.Raster.crs -============================= - -.. currentmodule:: pysyncrosim.raster - -.. autoproperty:: Raster.crs \ No newline at end of file diff --git a/docs/_autosummary/pysyncrosim.raster.Raster.dimensions.rst b/docs/_autosummary/pysyncrosim.raster.Raster.dimensions.rst deleted file mode 100644 index 2b8b7d0..0000000 --- a/docs/_autosummary/pysyncrosim.raster.Raster.dimensions.rst +++ /dev/null @@ -1,6 +0,0 @@ -pysyncrosim.raster.Raster.dimensions -==================================== - -.. currentmodule:: pysyncrosim.raster - -.. autoproperty:: Raster.dimensions \ No newline at end of file diff --git a/docs/_autosummary/pysyncrosim.raster.Raster.extent.rst b/docs/_autosummary/pysyncrosim.raster.Raster.extent.rst deleted file mode 100644 index bdf6e24..0000000 --- a/docs/_autosummary/pysyncrosim.raster.Raster.extent.rst +++ /dev/null @@ -1,6 +0,0 @@ -pysyncrosim.raster.Raster.extent -================================ - -.. currentmodule:: pysyncrosim.raster - -.. autoproperty:: Raster.extent \ No newline at end of file diff --git a/docs/_autosummary/pysyncrosim.raster.Raster.name.rst b/docs/_autosummary/pysyncrosim.raster.Raster.name.rst deleted file mode 100644 index 93db883..0000000 --- a/docs/_autosummary/pysyncrosim.raster.Raster.name.rst +++ /dev/null @@ -1,6 +0,0 @@ -pysyncrosim.raster.Raster.name -============================== - -.. currentmodule:: pysyncrosim.raster - -.. autoproperty:: Raster.name \ No newline at end of file diff --git a/docs/_autosummary/pysyncrosim.raster.Raster.resolution.rst b/docs/_autosummary/pysyncrosim.raster.Raster.resolution.rst deleted file mode 100644 index 3575022..0000000 --- a/docs/_autosummary/pysyncrosim.raster.Raster.resolution.rst +++ /dev/null @@ -1,6 +0,0 @@ -pysyncrosim.raster.Raster.resolution -==================================== - -.. currentmodule:: pysyncrosim.raster - -.. autoproperty:: Raster.resolution \ No newline at end of file diff --git a/docs/_autosummary/pysyncrosim.raster.Raster.rst b/docs/_autosummary/pysyncrosim.raster.Raster.rst deleted file mode 100644 index db7a3d3..0000000 --- a/docs/_autosummary/pysyncrosim.raster.Raster.rst +++ /dev/null @@ -1,39 +0,0 @@ -pysyncrosim.raster.Raster -========================= - -.. currentmodule:: pysyncrosim.raster - -.. autoclass:: Raster - - - -.. rubric:: Methods - -.. autosummary:: - :toctree: . - :nosignatures: - - - ~Raster.__init__ - ~Raster.values - - - - - - -.. rubric:: Attributes - -.. autosummary:: - :toctree: . - :nosignatures: - - - ~Raster.crs - ~Raster.dimensions - ~Raster.extent - ~Raster.name - ~Raster.resolution - ~Raster.source - - diff --git a/docs/_autosummary/pysyncrosim.raster.Raster.source.rst b/docs/_autosummary/pysyncrosim.raster.Raster.source.rst deleted file mode 100644 index 9bf8642..0000000 --- a/docs/_autosummary/pysyncrosim.raster.Raster.source.rst +++ /dev/null @@ -1,6 +0,0 @@ -pysyncrosim.raster.Raster.source -================================ - -.. currentmodule:: pysyncrosim.raster - -.. autoproperty:: Raster.source \ No newline at end of file diff --git a/docs/_autosummary/pysyncrosim.raster.Raster.values.rst b/docs/_autosummary/pysyncrosim.raster.Raster.values.rst deleted file mode 100644 index 04f4ec4..0000000 --- a/docs/_autosummary/pysyncrosim.raster.Raster.values.rst +++ /dev/null @@ -1,6 +0,0 @@ -pysyncrosim.raster.Raster.values -================================ - -.. currentmodule:: pysyncrosim.raster - -.. automethod:: Raster.values \ No newline at end of file diff --git a/docs/_autosummary/pysyncrosim.scenario.Scenario.rst b/docs/_autosummary/pysyncrosim.scenario.Scenario.rst index 0d702a9..b790927 100644 --- a/docs/_autosummary/pysyncrosim.scenario.Scenario.rst +++ b/docs/_autosummary/pysyncrosim.scenario.Scenario.rst @@ -16,7 +16,6 @@ ~Scenario.__init__ ~Scenario.copy - ~Scenario.datasheet_rasters ~Scenario.datasheets ~Scenario.delete ~Scenario.folders diff --git a/docs/conf.py b/docs/conf.py index d182e8b..bffbe5b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,7 +18,7 @@ # -- Project information ----------------------------------------------------- project = 'pysyncrosim' -copyright = '2025, ApexRMS' +copyright = '2026, ApexRMS' author = 'ApexRMS' # The full version, including alpha/beta/rc tags diff --git a/docs/module_summary.rst b/docs/module_summary.rst index 697fda4..7271378 100644 --- a/docs/module_summary.rst +++ b/docs/module_summary.rst @@ -13,7 +13,6 @@ API Reference helper library.Library project.Project - raster.Raster scenario.Scenario session.Session diff --git a/examples/input-raster.tif b/examples/input-raster.tif deleted file mode 100644 index b873c71..0000000 Binary files a/examples/input-raster.tif and /dev/null differ diff --git a/examples/spatial_demo.py b/examples/spatial_demo.py deleted file mode 100644 index 80b1863..0000000 --- a/examples/spatial_demo.py +++ /dev/null @@ -1,191 +0,0 @@ -# ============================================================================= -# # Set up environment -# ============================================================================= - -# Import packages - -import pandas as pd -import os -import pysyncrosim as ps -import rasterio -from matplotlib import pyplot - -# Load Session -mySession = ps.Session() - -# Check SyncroSim version -mySession.version() - -# Check which packages are installed -mySession.packages() - -# Install helloworldSpatial package -mySession.add_packages("helloworldSpatial") - -# Make sure it was installed -mySession.packages() - -# Update installed packages -mySession.update_packages("myPackage") - -# Remove installed packages -mySession.remove_packages("myPackage") - -# ============================================================================= -# # Create a modeling workflow -# ============================================================================= - -# Create a new Library using the helloworldSpatial package -myLibrary = ps.library(name = "spatialDemo", - session = mySession, - package = "helloworldSpatial", - overwrite = True) - -# You can also open an existing Library using the same function -myLibrary = ps.library(name = "spatialDemo", - session = mySession, - package = "helloworldSpatial") - -# Retrieve information about the Library instance attributes -myLibrary.info - -# Create (or open) a Project in this Library -myProject = myLibrary.projects(name = "Definitions") - -# When creating a new Scenario, uses "Definitions" Project by default -myScenario = myLibrary.scenarios(name = "Spatial Scenario") - -# Could also create / open a new Scenario using a Project class instance -myScenario = myProject.scenarios(name = "Spatial Scenario") - -# ============================================================================= -# # Modify Datasheets -# ============================================================================= - -# List Datasheets for this Scenario -myScenario.datasheets(optional=True) - -# Modify RunControl -myScenario.datasheets(name = "helloworldSpatial_RunControl") - -runControlDataFrame = pd.DataFrame({"MinimumIteration": [1], - "MaximumIteration": [5], - "MinimumTimestep": [1], - "MaximumTimestep": [10]}) - -myScenario.save_datasheet(name = "helloworldSpatial_RunControl", - data = runControlDataFrame) - -myScenario.datasheets(name = "helloworldSpatial_RunControl") - -# Modify InputDatasheet -myScenario.datasheets(name = "helloworldSpatial_InputDatasheet") - -InputDataFrame = pd.DataFrame({"mMean": [2], - "mSD": [4], - "InterceptRasterFile": [ - os.getcwd()+".\input-raster.tif"]}) - -myScenario.save_datasheet(name = "helloworldSpatial_InputDatasheet", - data = InputDataFrame) - -myScenario.datasheets(name = "helloworldSpatial_InputDatasheet") - -# Modify Pipeline Datasheet -myScenario.datasheets(name = "core_Pipeline") -pipelineDataFrame1 = myScenario.datasheets(name = "core_Pipeline") - -pipelineDataFrame2 = pd.DataFrame({"StageNameID": ["First Model", - "Second Model"], - "RunOrder": [1, 2]}) -pipelineDataFrame1 = pd.concat([pipelineDataFrame1, pipelineDataFrame2]) - -myScenario.save_datasheet(name = "core_Pipeline", data = pipelineDataFrame1) - -myScenario.datasheets(name = "core_Pipeline") - -# Copy the Scenario with all its Datasheets -myCopiedScenario = myScenario.copy(name = "My Copied Scenario") - - -# ============================================================================= -# # Run Scenarios -# ============================================================================= - -# Run using a Scenario method -myResultsScenario = myScenario.run(jobs=2) - -# Run using Library method -myResultsScenario = myLibrary.run(scenarios=myScenario, jobs=5) - -# Run multiple Scenarios at once (can use Scenario instances, names, or IDs) -myResultsScenarioAll = myLibrary.run(scenarios=[myScenario, - myCopiedScenario], - jobs=5) - -# ============================================================================= -# # View results -# ============================================================================= - -# Check Results Scenario attributes -myResultsScenario.info - -# Check if Scenario is a Results Scenario -myResultsScenario.is_result - -# Check the parent ID of a Results Scenario -myResultsScenario.parent_id - -# Check which Results Scenarios belong to a parent Scenario -myScenario.results() -myCopiedScenario.results() - -# Retrieve a specific results Scenario using its ID -myResultsScenario = myScenario.results(sid=3) - -# Check the run log -myResultsScenario.run_log() - -# View Results Scenario Datasheets -myResultsScenario.datasheets(name = "IntermediateDatasheet").head() -myResultsScenario.datasheets(name = "OutputDatasheet").head() - -# ============================================================================= -# # View spatial results -# ============================================================================= - -# Get a raster -spatialRaster = myResultsScenario.datasheet_rasters( - datasheet = "IntermediateDatasheet", - column = "OutputRasterFile", - iteration = 3, - timestep = 4) - -# View the raster metadata -spatialRaster - -# View cell values and plot raster using the Raster class instance -## use the raster object -spatialRaster.values() -pyplot.imshow(spatialRaster.values()) - -# You can also specify the band you want to extract -spatialRaster.values(band=1) - -# You can further modify the source TIF using rasterio -with rasterio.open(spatialRaster.source) as raster: - cell_values = raster.read() -cell_values - -with rasterio.open(spatialRaster[0].source) as raster: - rasterio.plot.show(raster) - -# Get multiple rasters in a list -spatialRasters = myResultsScenario.datasheet_rasters( - datasheet = "helloworldSpatial_IntermediateDatasheet", - column = "OutputRasterFile") - -spatialRasters[15] - -pyplot.imshow(spatialRasters[15].values(), cmap = "pink") -pyplot.show() diff --git a/pysyncrosim/__init__.py b/pysyncrosim/__init__.py index 358df77..109ed13 100644 --- a/pysyncrosim/__init__.py +++ b/pysyncrosim/__init__.py @@ -2,7 +2,6 @@ from pysyncrosim.library import Library from pysyncrosim.project import Project from pysyncrosim.scenario import Scenario -from pysyncrosim.raster import Raster from pysyncrosim.folder import Folder from pysyncrosim.environment import runtime_data_folder from pysyncrosim.environment import runtime_temp_folder diff --git a/pysyncrosim/raster.py b/pysyncrosim/raster.py deleted file mode 100644 index 585d403..0000000 --- a/pysyncrosim/raster.py +++ /dev/null @@ -1,157 +0,0 @@ -import rasterio -import os - -class Raster(object): - """ - A class to represent a raster object. - - """ - - def __init__(self, source, iteration=None, timestep=None): - self.__source = source - self.__name = self.__init_name(iteration, timestep) - self.__dimensions = self.__init_dimensions() - self.__extent = self.__init_extent() - self.__resolution = self.__init_resolution() - self.__crs = self.__init_crs() - - def __str__(self): - - return self.__to_string() - - def __repr__(self): - - return self.__to_string() - - def __to_string(self): - - s = "class: Raster\n" - s += "source: %s\n" % self.source - s += "name: %s\n" % self.name - s += "dimensions: %s\n" % self.dimensions - s += "resolution: %s\n" % self.resolution - s += "extent: %s\n" % self.extent - s += "crs: %s\n" % self.crs - - return s - - @property - def source(self): - """Gets the filepath of the raster""" - return self.__source - - @property - def name(self): - """Gets the name of the raster""" - return self.__name - - @property - def dimensions(self): - """Gets the dimensions of the raster""" - return self.__dimensions - - @property - def resolution(self): - """Gets the resolution of the raster""" - return self.__resolution - - @property - def extent(self): - """Gets the extent of the raster""" - return self.__extent - - @property - def crs(self): - """Gets the coordinate system of the raster""" - return self.__crs - - def values(self, band=None): - """ - Gets the values in each cell of the raster - - - Parameters - ---------- - band : Int, optional - The specific band to return. If None, then all bands in the raster - are returned in the array, with the first dimension of the array - corresponding to the band number. The default is None. - - Returns - ------- - values : numpy array - Array of values corresponding to the cell values in the raster. - - """ - - if band is None: - with rasterio.open(self.source) as raster: - values = raster.read() - if values.shape[0] == 1: - values = values[0] - return values - - else: - with rasterio.open(self.source) as raster: - values = raster.read(band) - return values - - def __init_name(self, iteration, timestep): - - prefix = os.path.splitext(os.path.basename(self.source))[0] - - if prefix.endswith(f".it{iteration}.ts{timestep}"): - return prefix - else: - return prefix + ".it" + str(iteration) + ".ts" + str(timestep) - - def __init_dimensions(self): - - dim_dict = {"height": [], "width": [], "cells": []} - - with rasterio.open(self.source) as raster: - - dim_dict["height"].append(raster.height) - dim_dict["width"].append(raster.width) - dim_dict["cells"].append(raster.height * raster.width) - - return dim_dict - - def __init_extent(self): - - extent_dict = {"xmin" : [], "xmax": [], "ymin": [], "ymax": []} - - with rasterio.open(self.source) as raster: - - extent_dict["xmin"].append(raster.bounds[0]) - extent_dict["xmax"].append(raster.bounds[2]) - extent_dict["ymin"].append(raster.bounds[1]) - extent_dict["ymax"].append(raster.bounds[3]) - - return extent_dict - - def __init_resolution(self): - - x_num = self.dimensions["width"][0] - y_num = self.dimensions["height"][0] - - x_range = self.extent["xmax"][0] - self.extent["ymin"][0] - y_range = self.extent["ymax"][0] - self.extent["ymin"][0] - - x_res = x_range / x_num - y_res = y_range / y_num - - res_dict = {"x": x_res, "y": y_res} - - return res_dict - - def __init_crs(self): - - with rasterio.open(self.source) as raster: - - crs = raster.crs - - return crs - - - diff --git a/pysyncrosim/scenario.py b/pysyncrosim/scenario.py index 9a2dff9..247cac3 100644 --- a/pysyncrosim/scenario.py +++ b/pysyncrosim/scenario.py @@ -403,95 +403,6 @@ def datasheets(self, name=None, summary=True, optional=False, empty=False, return_hidden, self.sid) return self.__datasheets - - def datasheet_rasters(self, datasheet, column=None, iteration=None, - timestep=None, filter_column=None, filter_value=None, - path_only=False): - """ - Retrieves spatial data columns from one or more SyncroSim Datasheets. - - Parameters - ---------- - datasheet : String - The name of a SyncroSim Datasheet containing raster data. - column : String - The column in the Datasheet containing the raster data. If no - column selected, then datasheet_rasters will attempt to find one. - iteration : Int, List, or Range, optional - The iteration to subset by. The default is None. - timestep : Int, List, or Range, optional - The timestep to subset by. The default is None. - filter_column : String - The column to filter the output rasters by - (e.g. "TransitionGroupId=20"). The default is None. - filter_value : String, Int, Logical - The value to filter the filter_column by. The default is None. - path_only : Logical - Instead of returning a Raster Class Instance, a filepath to the - raster is returned. The default is False. - - Returns - ------- - Raster or List of Rasters - Raster class instance or List of these. - - """ - # Validate inputs - self.__validate_datasheet_raster_inputs( - datasheet, column, iteration, timestep) - - # Check that Datasheet has package prefix - datasheet = self.library._Library__check_datasheet_name(datasheet) - - # Retrieve Datasheet as DataFrame - d = self.datasheets(name = datasheet, filter_column = filter_column, - filter_value = filter_value, show_full_paths = False) - - if d.empty: - raise ValueError(f"Datasheet {datasheet} does not contain data.") - - # Check if column is raster column - column = self.__retrieve_raster_column(datasheet, column) - - # Filter data by iteration and timestep - d = self.__filter_by_iteration(iteration, d) - d = self.__filter_by_timestep(timestep, d) - - # Determine which folder to look for raster tifs - if self.__env is None: - lib_dir = self.__find_output_fpath( - self.library.location + ".data", datasheet) - - else: - # TODO: test update - do we need to also search .data when in ssim env? - e = _environment() - lib_dir = e.library_filepath.item() + ".temp" - - # Search for raster tifs in data or temp directories - raster_tifs = d[column].values - rpaths = self.__list_datasheet_rasters(raster_tifs, lib_dir) - - # Return only filepaths to rasters if path_only is True - if path_only: - return rpaths - - # Iterate through all raster files in datasheet and store in list - raster_list = [] - - for rpath in rpaths: - - # Open and append each raster from the Datasheet - data_row = d[d[column] == os.path.basename(rpath)] - iter_val = None if "Iteration" not in d.columns else data_row.Iteration.item() - ts = None if "Timestep" not in d.columns else data_row.Timestep.item() - raster = ps.Raster(rpath, iteration=iter_val, timestep=ts) - raster_list.append(raster) - - if len(raster_list) == 1: - return raster_list[0] - else: - return raster_list - def save_datasheet(self, name, data, append=False): """ Saves a pandas DataFrame as a SyncroSim Datasheet. diff --git a/requirements.txt b/requirements.txt index 9044267..ec22e69 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ numpy pandas -rasterio diff --git a/setup.py b/setup.py index 5656d7a..092b6e0 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -# Copyright (c) 2025 Apex Resource Management Solution Ltd. (ApexRMS). All rights reserved. +# Copyright (c) 2026 Apex Resource Management Solution Ltd. (ApexRMS). All rights reserved. # MIT License from setuptools import setup, find_packages @@ -22,7 +22,7 @@ author_email="pysyncrosim@syncrosim.com", url="https://syncrosim.com/", packages=find_packages(exclude=("tests",)), - install_requires=["numpy", "pandas", "rasterio"], + install_requires=["numpy", "pandas"], extras_require={ "dev": ["pytest", "build", "twine"], }, diff --git a/tests/spatial-example.ssimbak b/tests/spatial-example.ssimbak index 5a09db4..6152a74 100644 Binary files a/tests/spatial-example.ssimbak and b/tests/spatial-example.ssimbak differ diff --git a/tests/test_pysyncrosim.py b/tests/test_pysyncrosim.py index fde3bcf..38eda80 100644 --- a/tests/test_pysyncrosim.py +++ b/tests/test_pysyncrosim.py @@ -12,8 +12,8 @@ session_path = None test_lib_path = os.path.join(temp_path.name, "stsimLibrary.ssim") lib_name = "spatial-example.ssim" -#git_repo_path = "C:/Users/VickiZhang/Documents/GH_ApexRMS" -git_repo_path = "C:/gitprojects" +git_repo_path = "C:/Users/VickiZhang/Documents/GH_ApexRMS" +# git_repo_path = "C:/gitprojects" lib_path = os.path.join(git_repo_path, "pysyncrosim/tests", lib_name) lib_backup_path = os.path.join(git_repo_path, "pysyncrosim/tests", "spatial-example.ssimbak") @@ -931,133 +931,6 @@ def test_scenario_run_and_results(): assert isinstance(myResultsScenario.run_log(), pd.DataFrame) assert not isinstance(myScenario.run_log(), pd.DataFrame) - # Test datasheet_rasters - with pytest.raises(TypeError, match="datasheet must be a String"): - myResultsScenario.datasheet_rasters(datasheet=1, column="test") - - with pytest.raises(TypeError, match="column must be a String"): - myResultsScenario.datasheet_rasters(datasheet="stsim_test", column=1) - - with pytest.raises(TypeError, match="iteration must be an Integer"): - myResultsScenario.datasheet_rasters(datasheet="stsim_test", column="test", - iteration="test") - - with pytest.raises(TypeError, match="timestep must be an Integer"): - myResultsScenario.datasheet_rasters(datasheet="stsim_test", column="test", - timestep="test") - - with pytest.raises(RuntimeError, - match="The datasheet does not belong to this library: stsim_test"): - myResultsScenario.datasheet_rasters(datasheet="stsim_test", column="test") - - with pytest.raises(ValueError, - match="No raster columns found in Datasheet"): - myResultsScenario.datasheet_rasters(datasheet="stsim_OutputStratum") - - with pytest.raises( - ValueError, - match="Column test not found in Datasheet"): - myResultsScenario.datasheet_rasters(datasheet="stsim_OutputSpatialState", - column="test") - - with pytest.raises( - ValueError, - match="Specified iteration above range of plausible values"): - myResultsScenario.datasheet_rasters(datasheet="stsim_OutputSpatialState", - column="Filename", - iteration=1000) - - with pytest.raises(ValueError, match="iteration cannot be below 1"): - myResultsScenario.datasheet_rasters(datasheet="stsim_OutputSpatialState", - column="Filename", - iteration=0) - - with pytest.raises(ValueError, - match="Some iteration values outside of range"): - myResultsScenario.datasheet_rasters(datasheet="stsim_OutputSpatialState", - column="Filename", - iteration=[1, 2, 1000]) - - with pytest.raises( - ValueError, - match="Specified timestep above range of plausible values"): - myResultsScenario.datasheet_rasters(datasheet="stsim_OutputSpatialState", - column="Filename", - timestep=9999) - - with pytest.raises( - ValueError, - match="Specified timestep below range of plausible values"): - myResultsScenario.datasheet_rasters(datasheet="stsim_OutputSpatialState", - column="Filename", - timestep=0) - - with pytest.raises(ValueError, - match="Some timestep values outside of range"): - myResultsScenario.datasheet_rasters(datasheet="stsim_OutputSpatialState", - column="Filename", - timestep=[1999, 2002, 2003]) - - with pytest.raises( - ValueError, - match = "Must specify a filter_value to filter the filter_column"): - myResultsScenario.datasheet_rasters( - datasheet="stsim_OutputSpatialState", - column = None, - filter_column="OutputSpatialStateId") - - with pytest.raises( - ValueError, - match = "filter column test not in Datasheet" - ): - myResultsScenario.datasheet_rasters( - datasheet="stsim_OutputSpatialState", - column = None, - filter_column="test", - filter_value="test") - - with pytest.raises( - RuntimeError, - match="Cannot find a value for: test"): - myResultsScenario.datasheet_rasters( - datasheet="stsim_OutputSpatialState", - column = None, - filter_column="OutputSpatialStateId", - filter_value="test") - - raster1 = myResultsScenario.datasheet_rasters( - datasheet="stsim_OutputSpatialState", column="Filename", - iteration=1, timestep=2001) - assert isinstance(raster1, ps.Raster) - - raster2 = myResultsScenario.datasheet_rasters( - datasheet="stsim_OutputSpatialState", column="Filename") - assert len(raster2) > 1 - assert all([isinstance(x, ps.Raster) for x in raster2]) - - raster3 = myResultsScenario.datasheet_rasters( - datasheet = "stsim_OutputSpatialState", - column = None, - filter_column="Timestep", - filter_value=2001) - assert isinstance(raster3[0], ps.Raster) - - # Test raster class attributes - assert os.path.isfile(raster1.source) - assert isinstance(raster1.name, str) - assert raster1.name.endswith(".it1.ts2001") - assert isinstance(raster1.dimensions, dict) - assert all([ - x in raster1.dimensions.keys() for x in [ - "height", "width", "cells"]]) - assert isinstance(raster1.extent, dict) - assert all([ - x in raster1.extent.keys() for x in [ - "xmin", "xmax", "ymin", "ymax"]]) - assert isinstance(raster1.crs, rasterio.crs.CRS) - assert isinstance(raster1.values(), np.ndarray) - assert isinstance(raster1.values(band=1), np.ndarray) - myLibrary.delete(force=True) def test_scenario_copy_dep_delete():