Skip to content

Commit

Permalink
fix number_of_primaries calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
grzanka committed Mar 12, 2024
1 parent 491c4cc commit 540d73f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pymchelper/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def add_page(self, page):
"""
new_page = copy.deepcopy(page)
new_page.estimator = self
self.pages += (new_page,)
self.pages += (new_page, )

def axis(self, axis_id : int) -> Optional[MeshAxis]:
def axis(self, axis_id: int) -> Optional[MeshAxis]:
"""
Mesh axis selector method based on integer id's.
Expand Down Expand Up @@ -133,6 +133,7 @@ def average_with_nan(estimator_list, error_estimate=ErrorEstimate.stderr):
if not estimator_list:
return None
result = copy.deepcopy(estimator_list[0])
result.number_of_primaries = sum([estimator.number_of_primaries for estimator in estimator_list])
for page_no, page in enumerate(result.pages):
page.data_raw = np.nanmean([estimator.pages[page_no].data_raw for estimator in estimator_list], axis=0)
result.file_counter = len(estimator_list)
Expand All @@ -141,7 +142,8 @@ def average_with_nan(estimator_list, error_estimate=ErrorEstimate.stderr):
# s : corrected sample standard deviation
for page_no, page in enumerate(result.pages):
page.error_raw = np.nanstd([estimator.pages[page_no].data_raw for estimator in estimator_list],
axis=0, ddof=1)
axis=0,
ddof=1)

# if user requested standard error then we calculate it as:
# S = stderr = stddev / sqrt(n), or in other words,
Expand Down
2 changes: 2 additions & 0 deletions pymchelper/input_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def fromfilelist(input_file_list, error: ErrorEstimate = ErrorEstimate.stderr, n
logger.warning("File %s could not be read", filename)
return None

result.number_of_primaries += current_estimator.number_of_primaries

for current_page, result_page in zip(current_estimator.pages, result.pages):
# got a page with "concatenate normalisation"
if getattr(current_page, 'page_normalized', 2) == 4:
Expand Down

0 comments on commit 540d73f

Please sign in to comment.