Skip to content

Commit

Permalink
Merge fc75e01 into fbab2ab
Browse files Browse the repository at this point in the history
  • Loading branch information
JoranAngevaare authored Jun 20, 2023
2 parents fbab2ab + fc75e01 commit cfd2d74
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion optim_esm_tools/analyze/cmip_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def read_ds(
variable_of_interest: ty.Tuple[str] = ('tas',),
max_time: ty.Optional[ty.Tuple[int, int, int]] = (2100, 1, 1),
min_time: ty.Optional[ty.Tuple[int, int, int]] = None,
strict:bool =True,
strict: bool = True,
_ma_window: int = 10,
_cache: bool = True,
_file_name: str = 'merged.nc',
Expand Down
11 changes: 7 additions & 4 deletions optim_esm_tools/analyze/region_finding.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def _plot_mask_time_series(
self, masks, time_series_joined=True, only_rm=False, axes=None
):
legend_kw = oet.utils.legend_kw(
loc='upper left', bbox_to_anchor=None, mode=None, ncol=4
loc='upper left', bbox_to_anchor=None, mode=None, ncol=2
)
for label, mask_2d in zip(self.labels, masks.values()):
x, y = self._mask_to_coord(mask_2d)
Expand Down Expand Up @@ -312,7 +312,7 @@ def _plot_masks(
)
if legend:
plt.legend(**oet.utils.legend_kw())
plt.suptitle(f'Clusters {self.title}', y=0.95)
plt.suptitle(f'Clusters {self.title}', y=0.97 if len(masks) < 4 else 0.99)
return ax

def _plot_basic_map(self):
Expand All @@ -336,11 +336,14 @@ def _plot_basic_map(self):

@plt_show
def plot_mask_time_series(self, masks_and_clusters, time_series_joined=True):
if not len(masks_and_clusters[0]):
self.log.warning('No clusters found!')
return
res = self._plot_mask_time_series(
masks_and_clusters, time_series_joined=time_series_joined
)
if time_series_joined:
self.save(f'{self.title_label}_all_clusters')
if time_series_joined and masks_and_clusters:
self.save(f'{self.title_label}_time_series_all_clusters')
return res

@apply_options
Expand Down
5 changes: 3 additions & 2 deletions test/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ def test_apply_relative_units(self, unit='relative', refresh=False):
data_set = oet.analyze.cmip_handler.read_ds(
os.path.split(
year_means(
get_file_from_pangeo('ssp585', refresh=refresh),
refresh=refresh))[0],
get_file_from_pangeo('ssp585', refresh=refresh), refresh=refresh
)
)[0],
condition_kwargs=dict(unit=unit),
_file_name='test_merged.nc',
)
Expand Down

0 comments on commit cfd2d74

Please sign in to comment.