Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to set loglevel #765

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ Removed:
- Reduce memory requirements of `TropCyclone.from_tracks` [#749](https://github.com/CLIMADA-project/climada_python/pull/749)
- Support for different wind speed and pressure units in `TCTracks` when running `TropCyclone.from_tracks` [#749](https://github.com/CLIMADA-project/climada_python/pull/749)
- Changed the parallel package from Pathos to Multiproess in the unsequa module [#763](https://github.com/CLIMADA-project/climada_python/pull/763)

- Allow setting the loglevel in unsequa module [#765](https://github.com/CLIMADA-project/climada_python/pull/765)
-
### Fixed

- `util.lines_polys_handler` solve polygon disaggregation issue in metre-based projection [#666](https://github.com/CLIMADA-project/climada_python/pull/666)
Expand Down
13 changes: 9 additions & 4 deletions climada/engine/unsequa/calc_cost_benefit.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def __init__(



def uncertainty(self, unc_data, processes=1, **cost_benefit_kwargs):
def uncertainty(self, unc_data, processes=1, loglevel='ERROR', **cost_benefit_kwargs):
"""
Computes the cost benefit for each sample in unc_output.sample_df.

Expand All @@ -152,6 +152,9 @@ def uncertainty(self, unc_data, processes=1, **cost_benefit_kwargs):
processes : int, optional
Number of CPUs to use for parralel computations.
The default is 1 (not parallel)
loglevel: str
Level of warning for the climada logger during the computation.
The default is "ERROR".
cost_benefit_kwargs : keyword arguments
Keyword arguments passed on to climada.engine.CostBenefit.calc()

Expand All @@ -170,7 +173,9 @@ def uncertainty(self, unc_data, processes=1, **cost_benefit_kwargs):
See Also
--------
climada.engine.cost_benefit:
Compute risk and adptation option cost benefits.
compute risk and adptation option cost benefits.
climada.util.log_level:
set log level

"""

Expand Down Expand Up @@ -205,7 +210,7 @@ def uncertainty(self, unc_data, processes=1, **cost_benefit_kwargs):
self.est_comp_time(unc_data.n_samples, elapsed_time, processes)

#Compute impact distributions
with log_level(level='ERROR', name_prefix='climada'):
with log_level(level=loglevel, name_prefix='climada'):
p_iterator = self._sample_parallel_iterator(
samples_df.iterrows(),
ent_input_var=self.ent_input_var,
Expand All @@ -227,7 +232,7 @@ def uncertainty(self, unc_data, processes=1, **cost_benefit_kwargs):
)

#Perform the actual computation
with log_level(level='ERROR', name_prefix='climada'):
with log_level(level=loglevel, name_prefix='climada'):
[imp_meas_present,
imp_meas_future,
tot_climate_risk,
Expand Down
15 changes: 11 additions & 4 deletions climada/engine/unsequa/calc_impact.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ def uncertainty(self,
rp=None,
calc_eai_exp=False,
calc_at_event=False,
processes=1
processes=1,
loglevel='ERROR'
):
"""
Computes the impact for each sample in unc_data.sample_df.
Expand Down Expand Up @@ -160,6 +161,9 @@ def uncertainty(self,
processes : int, optional
Number of CPUs to use for parralel computations.
The default is 1 (not parallel)
loglevel: str
Level of warning for the climada logger during the computation.
The default is "ERROR".

Returns
-------
Expand All @@ -175,7 +179,10 @@ def uncertainty(self,

See Also
--------
climada.engine.impact: Compute risk.
climada.engine.impact:
compute impact and risk.
climada.util.log_level:
set log level

"""

Expand Down Expand Up @@ -212,7 +219,7 @@ def uncertainty(self,
self.est_comp_time(unc_sample.n_samples, elapsed_time, processes)

#Compute impact distributions
with log_level(level='ERROR', name_prefix='climada'):
with log_level(level=loglevel, name_prefix='climada'):
p_iterator = self._sample_parallel_iterator(
samples_df.iterrows(),
exp_input_var=self.exp_input_var,
Expand All @@ -235,7 +242,7 @@ def uncertainty(self,
)

#Perform the actual computation
with log_level(level='ERROR', name_prefix='climada'):
with log_level(level=loglevel, name_prefix='climada'):
[aai_agg_list, freq_curve_list,
eai_exp_list, at_event_list] = list(zip(*imp_metrics))

Expand Down