@@ -1594,49 +1594,88 @@ def set_geospatial_data(self, weather_ds: xr.Dataset, meta_df: pd.DataFrame ) ->
1594
1594
self .weather_data , self .meta_data = weather_ds , meta_df
1595
1595
1596
1596
1597
+ # def addJob(
1598
+ # self,
1599
+ # func: Callable = None,
1600
+ # func_params: dict = {},
1601
+ # see_added: bool = False,
1602
+ # ):
1603
+ # """
1604
+ # Add a pvdeg function to the scenario pipeline
1605
+
1606
+ # Parameters:
1607
+ # -----------
1608
+ # func : function
1609
+ # pvdeg function to use for geospatial analysis.
1610
+ # *Note: geospatial analysis is only available with a limited subset of pvdeg
1611
+ # functions*
1612
+ # Current supported functions for geospatial analysis: ``pvdeg.standards.standoff``,
1613
+ # ``pvdeg.humidity.module``, ``pvdeg.letid.calc_letid_outdoors``
1614
+ # func_params : dict
1615
+ # job specific keyword argument dictionary to provide to the function
1616
+ # see_added : bool
1617
+ # set flag to get a userWarning notifying the user of the job added
1618
+ # to the pipeline in method call. ``default = False``
1619
+ # """
1620
+ # try:
1621
+ # pvdeg.geospatial.template_parameters(func)
1622
+ # except ValueError:
1623
+ # return ValueError(
1624
+ # f"{func.__name__} does does not have a valid geospatial results template or does not exist"
1625
+ # )
1626
+
1627
+ # geo_job_dict = {"geospatial_job": {"job": func, "params": func_params}}
1628
+
1629
+ # self.pipeline = geo_job_dict
1630
+
1631
+ # if see_added:
1632
+ # message = f"{func.__name__} added to pipeline as \n {geo_job_dict}"
1633
+ # warnings.warn(message, UserWarning)
1634
+
1597
1635
def addJob (
1598
1636
self ,
1599
- func : Callable = None ,
1637
+ func : Callable ,
1638
+ template : xr .Dataset = None ,
1600
1639
func_params : dict = {},
1601
- see_added : bool = False ,
1602
- ):
1640
+ see_added : bool = False
1641
+ ) -> None :
1603
1642
"""
1604
- Add a pvdeg function to the scenario pipeline
1643
+ Add a pvdeg geospatial function to the scenario pipeline. If no template is provided, `addJob` attempts to use `geospatial.auto_template` this will raise an
1605
1644
1606
1645
Parameters:
1607
1646
-----------
1608
1647
func : function
1609
- pvdeg function to use for geospatial analysis.
1610
- *Note: geospatial analysis is only available with a limited subset of pvdeg
1611
- functions*
1612
- Current supported functions for geospatial analysis: ``pvdeg.standards.standoff``,
1613
- ``pvdeg.humidity.module``, ``pvdeg.letid.calc_letid_outdoors``
1648
+ pvdeg function to use for geospatial analysis.
1649
+ template : xarray.Dataset
1650
+ Template for output data. Only required if a function is not supported by `geospatial.auto_template`.
1614
1651
func_params : dict
1615
1652
job specific keyword argument dictionary to provide to the function
1616
1653
see_added : bool
1617
1654
set flag to get a userWarning notifying the user of the job added
1618
- to the pipeline in method call. ``default = False``
1655
+ to the pipeline in method call. ``default = False``
1619
1656
"""
1620
- try :
1621
- pvdeg .geospatial .template_parameters (func )
1622
- except ValueError :
1623
- return ValueError (
1624
- f"{ func .__name__ } does does not have a valid geospatial results template or does not exist"
1625
- )
1626
1657
1627
- geo_job_dict = {"geospatial_job" : {"job" : func , "params" : func_params }}
1658
+ if template is None :
1659
+
1660
+ # take the weather datapoints specified by metadata and create a template based on them.
1661
+ geo_weather_sub = self .weather_data .sel (gid = self .meta_data .index )
1662
+ template = pvdeg .geospatial .auto_template (func = func , ds_gids = self .weather_data )
1628
1663
1629
- self .pipeline = geo_job_dict
1664
+ self .template = template
1665
+ self .func = func
1666
+ self .func_params = func_params
1630
1667
1631
1668
if see_added :
1632
- message = f"{ func .__name__ } added to pipeline as \n { geo_job_dict } "
1669
+ message = f"{ func .__name__ } added to scenario with arguments { func_params } using template: { template } "
1633
1670
warnings .warn (message , UserWarning )
1634
1671
1672
+
1673
+
1635
1674
def run (self , hpc_worker_conf : Optional [dict ] = None ) -> None :
1636
1675
"""
1637
- Run the function in the geospatial pipeline .
1638
- GeospatialScenario only supports one geospatial pipeline job at a time
1639
- unlike Scenario which supports unlimited conventional pipeline jobs.
1676
+ Run the geospatial scenario stored in the geospatial scenario object .
1677
+
1678
+ Only supports one function at a time. Unlike ` Scenario` which supports unlimited conventional pipeline jobs.
1640
1679
Results are stored in the `GeospatialScenario.results` attribute.
1641
1680
1642
1681
Creates a dask cluster or client using the hpc_worker_conf parameter.
@@ -1675,20 +1714,14 @@ def run(self, hpc_worker_conf: Optional[dict] = None) -> None:
1675
1714
"""
1676
1715
client = pvdeg .geospatial .start_dask (hpc = hpc_worker_conf )
1677
1716
1678
- geo_weather_sub = self .weather_data .sel (gid = self .meta_data .index )
1679
-
1680
- func = self .pipeline ["geospatial_job" ]["job" ]
1681
-
1682
- if func == pvdeg .standards .standoff or func == pvdeg .humidity .module :
1683
- geo = {
1684
- "func" : func ,
1685
- "weather_ds" : geo_weather_sub ,
1686
- "meta_df" : self .meta_data ,
1687
- }
1688
-
1689
- analysis_result = pvdeg .geospatial .analysis (** geo )
1717
+ analysis_result = pvdeg .geospatial .analysis (
1718
+ weather_ds = self .weather_data ,
1719
+ meta_df = self .meta_data ,
1720
+ func = self .func ,
1721
+ template = self .template , # provided or generated via autotemplate in GeospatialScenario.addJob
1722
+ )
1690
1723
1691
- self .results = analysis_result
1724
+ self .results = analysis_result
1692
1725
1693
1726
client .shutdown ()
1694
1727
0 commit comments