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

Make sure outputs for 1D RM synthesis are actually the dType that user requested #150

Merged
merged 2 commits into from
Dec 5, 2024
Merged
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
26 changes: 12 additions & 14 deletions RMtools_1D/do_RMsynth_1D.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,9 @@ def run_rmsynth(
if debug:
rmsFig = plt.figure(facecolor="w", figsize=(12.0, 8))
ax = rmsFig.add_subplot(111)
ax.plot(
freqArr_Hz / 1e9, dQUArr, marker="o", color="k", lw=0.5, label="noise <QU>"
)
ax.plot(freqArr_Hz / 1e9, dQArr, marker="o", color="b", lw=0.5, label="noise Q")
ax.plot(freqArr_Hz / 1e9, dUArr, marker="o", color="r", lw=0.5, label="noise U")
ax.plot(freqArr_GHz, dQUArr, marker="o", color="k", lw=0.5, label="noise <QU>")
ax.plot(freqArr_GHz, dQArr, marker="o", color="b", lw=0.5, label="noise Q")
ax.plot(freqArr_GHz, dUArr, marker="o", color="r", lw=0.5, label="noise U")
xRange = (np.nanmax(freqArr_Hz) - np.nanmin(freqArr_Hz)) / 1e9
ax.set_xlim(
np.min(freqArr_Hz) / 1e9 - xRange * 0.05,
Expand All @@ -261,9 +259,9 @@ def run_rmsynth(

# Calculate some wavelength parameters
lambdaSqArr_m2 = np.power(speed_of_light.value / freqArr_Hz, 2.0)
dFreq_Hz = np.nanmin(np.abs(np.diff(freqArr_Hz)))
# dFreq_Hz = np.nanmin(np.abs(np.diff(freqArr_Hz)))
lambdaSqRange_m2 = np.nanmax(lambdaSqArr_m2) - np.nanmin(lambdaSqArr_m2)
dLambdaSqMin_m2 = np.nanmin(np.abs(np.diff(lambdaSqArr_m2)))
# dLambdaSqMin_m2 = np.nanmin(np.abs(np.diff(lambdaSqArr_m2)))
dLambdaSqMax_m2 = np.nanmax(np.abs(np.diff(lambdaSqArr_m2)))

# Set the Faraday depth range
Expand Down Expand Up @@ -454,13 +452,14 @@ def run_rmsynth(
tmpFig.show()

# add array dictionary
# Force dtypes as given by input
aDict = dict()
aDict["phiArr_radm2"] = phiArr_radm2
aDict["phi2Arr_radm2"] = phi2Arr_radm2
aDict["RMSFArr"] = RMSFArr
aDict["freqArr_Hz"] = freqArr_Hz
aDict["weightArr"] = weightArr
aDict["dirtyFDF"] = dirtyFDF
aDict["phiArr_radm2"] = phiArr_radm2.astype(dtFloat)
aDict["phi2Arr_radm2"] = phi2Arr_radm2.astype(dtFloat)
aDict["RMSFArr"] = RMSFArr.astype(dtComplex)
aDict["freqArr_Hz"] = freqArr_Hz.astype(dtFloat)
aDict["weightArr"] = weightArr.astype(dtFloat)
aDict["dirtyFDF"] = dirtyFDF.astype(dtComplex)

if verbose:
# Print the results to the screen
Expand Down Expand Up @@ -582,7 +581,6 @@ def readFile(dataFile, nBits, verbose=True, debug=False):
print("... success.")
data = [freqArr_Hz, QArr, UArr, dQArr, dUArr]

noStokesI = True
except Exception:
if verbose:
print("...failed.")
Expand Down