Skip to content

Commit

Permalink
Improve long string wrapping, thanks @ns-rse
Browse files Browse the repository at this point in the history
  • Loading branch information
SylviaWhittle committed Nov 23, 2023
1 parent d0ea520 commit a3a94da
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions topofileformats/asd.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def __init__(self, analogue_digital_range, max_voltage, scaling_factor, resoluti
self.scaling_factor = scaling_factor
self.resolution = resolution
logger.info(
f"created voltage converter. ad_range: {analogue_digital_range} -> {self.ad_range}, \
max voltage: {max_voltage}, scaling factor: {scaling_factor}, resolution: {resolution}"
f"created voltage converter. ad_range: {analogue_digital_range} -> {self.ad_range}, "
f"max voltage: {max_voltage}, scaling factor: {scaling_factor}, resolution: {resolution}"
)


Expand Down Expand Up @@ -123,20 +123,20 @@ def calculate_scaling_factor(
"""
if channel == "TP":
logger.info(
f"Scaling factor: Type: {channel} -> TP | piezo extension {z_piezo_gain} \
* piezo gain {z_piezo_extension} = scaling factor {z_piezo_gain * z_piezo_extension}"
f"Scaling factor: Type: {channel} -> TP | piezo extension {z_piezo_gain} "
f"* piezo gain {z_piezo_extension} = scaling factor {z_piezo_gain * z_piezo_extension}"
)
return z_piezo_gain * z_piezo_extension
if channel == "ER":
logger.info(
f"Scaling factor: Type: {channel} -> ER | - scanner sensitivity {-scanner_sensitivity} \
= scaling factor {-scanner_sensitivity}"
f"Scaling factor: Type: {channel} -> ER | - scanner sensitivity {-scanner_sensitivity} "
f"= scaling factor {-scanner_sensitivity}"
)
return -scanner_sensitivity
if channel == "PH":
logger.info(
f"Scaling factor: Type: {channel} -> PH | - phase sensitivity {-phase_sensitivity} \
= scaling factor {-phase_sensitivity}"
f"Scaling factor: Type: {channel} -> PH | - phase sensitivity {-phase_sensitivity} "
f"= scaling factor {-phase_sensitivity}"
)
return -phase_sensitivity

Expand Down Expand Up @@ -183,31 +183,25 @@ def load_asd(file_path: Path, channel: str):
header_dict = read_header_file_version_2(open_file)
else:
raise ValueError(
f"File version {file_version} unknown. Please add support if you\
know how to decode this file version."
f"File version {file_version} unknown. Please add support if you "
"know how to decode this file version."
)
logger.info(f"header dict: \n{header_dict}")

pixel_to_nanometre_scaling_factor_x = header_dict["x_nm"] / header_dict["x_pixels"]
pixel_to_nanometre_scaling_factor_y = header_dict["y_nm"] / header_dict["y_pixels"]
if pixel_to_nanometre_scaling_factor_x != pixel_to_nanometre_scaling_factor_y:
logger.warning(
f"Resolution of image is different in x and y directions:\
x: {pixel_to_nanometre_scaling_factor_x}\
y: {pixel_to_nanometre_scaling_factor_y}"
f"Resolution of image is different in x and y directions:"
f"x: {pixel_to_nanometre_scaling_factor_x}"
f"y: {pixel_to_nanometre_scaling_factor_y}"
)
pixel_to_nanometre_scaling_factor = pixel_to_nanometre_scaling_factor_x

if channel == header_dict["channel1"]:
logger.info(
f"Requested channel {channel} matches first channel in file: \
{header_dict['channel1']}"
)
logger.info(f"Requested channel {channel} matches first channel in file: " f"{header_dict['channel1']}")
elif channel == header_dict["channel2"]:
logger.info(
f"Requested channel {channel} matches second channel in file: \
{header_dict['channel2']}"
)
logger.info(f"Requested channel {channel} matches second channel in file: " f"{header_dict['channel2']}")

# Skip first channel data
_size_of_frame_header = header_dict["frame_header_length"]
Expand All @@ -219,8 +213,8 @@ def load_asd(file_path: Path, channel: str):
_ = open_file.read(length_of_all_first_channel_frames)
else:
raise ValueError(
f"Channel {channel} not found in this file's available channels: \
{header_dict['channel1']}, {header_dict['channel2']}"
f"Channel {channel} not found in this file's available channels: "
f"{header_dict['channel1']}, {header_dict['channel2']}"
)

scaling_factor = calculate_scaling_factor(
Expand Down Expand Up @@ -756,8 +750,7 @@ def create_analogue_digital_converter(analogue_digital_range, scaling_factor, re
)
else:
raise ValueError(
f"Analogue to digital range hex value {analogue_digital_range} has no known \
analogue-digital mapping."
f"Analogue to digital range hex value {analogue_digital_range} has no known " "analogue-digital mapping."
)
logger.info(f"Analogue to digital mapping | Range: {analogue_digital_range} -> {mapping}")
logger.info(f"Converter: {converter}")
Expand Down

1 comment on commit a3a94da

@ns-rse
Copy link
Collaborator

@ns-rse ns-rse commented on a3a94da Nov 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.