From a2cdea1f9f67355a1df8c8e2d95f97e0a8c388b4 Mon Sep 17 00:00:00 2001 From: Dan Nowacki Date: Wed, 29 May 2024 11:35:09 -0700 Subject: [PATCH] Use raw strings for sep (#231) --- stglib/aqd/hdr2cdf.py | 6 +++--- stglib/aqd/hrhdr2cdf.py | 8 ++++---- stglib/aqd/wvswad2cdf.py | 4 ++-- stglib/argonaut.py | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/stglib/aqd/hdr2cdf.py b/stglib/aqd/hdr2cdf.py index cfcc2bb2..43be404d 100755 --- a/stglib/aqd/hdr2cdf.py +++ b/stglib/aqd/hdr2cdf.py @@ -73,7 +73,7 @@ def load_sen(basefile): SEN = pd.read_csv( senfile, header=None, - sep="\s+", + sep=r"\s+", usecols=[0, 1, 2, 3, 4, 5, 8, 10, 11, 12, 13, 14, 15, 16], ) @@ -119,7 +119,7 @@ def load_amp_vel(RAW, basefile): for n in [1, 2, 3]: afile = basefile + ".a" + str(n) - a = pd.read_csv(afile, header=None, sep="\s+") + a = pd.read_csv(afile, header=None, sep=r"\s+") if "bindist" in RAW: coords = [RAW["time"], RAW["bindist"]] @@ -129,7 +129,7 @@ def load_amp_vel(RAW, basefile): RAW["AMP" + str(n)] = xr.DataArray(a, dims=("time", "bindist"), coords=coords) vfile = basefile + ".v" + str(n) - v = pd.read_csv(vfile, header=None, sep="\s+") + v = pd.read_csv(vfile, header=None, sep=r"\s+") if RAW.attrs["AQDCoordinateSystem"] == "BEAM": thevars = {1: "VEL1", 2: "VEL2", 3: "VEL3"} diff --git a/stglib/aqd/hrhdr2cdf.py b/stglib/aqd/hrhdr2cdf.py index 8d0a9354..68d9a93e 100644 --- a/stglib/aqd/hrhdr2cdf.py +++ b/stglib/aqd/hrhdr2cdf.py @@ -73,7 +73,7 @@ def load_sen(ds): SEN = pd.read_csv( senfile, header=None, - sep="\s+", + sep=r"\s+", usecols=[0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17, 18], ) @@ -142,7 +142,7 @@ def load_amp_vel_cor(RAW, basefile): for n in [1, 2, 3]: afile = basefile + ".a" + str(n) - a = pd.read_csv(afile, header=None, sep="\s+") + a = pd.read_csv(afile, header=None, sep=r"\s+") spb = int(RAW.attrs["AQDHRSamplesPerBurst"]) @@ -160,7 +160,7 @@ def load_amp_vel_cor(RAW, basefile): ) vfile = basefile + ".v" + str(n) - v = pd.read_csv(vfile, header=None, sep="\s+") + v = pd.read_csv(vfile, header=None, sep=r"\s+") if RAW.attrs["AQDHRCoordinateSystem"] == "BEAM": thevars = {1: "VEL1", 2: "VEL2", 3: "VEL3"} @@ -177,7 +177,7 @@ def load_amp_vel_cor(RAW, basefile): try: cfile = basefile + ".c" + str(n) - c = pd.read_csv(cfile, header=None, sep="\s+") + c = pd.read_csv(cfile, header=None, sep=r"\s+") spb = int(RAW.attrs["AQDHRSamplesPerBurst"]) diff --git a/stglib/aqd/wvswad2cdf.py b/stglib/aqd/wvswad2cdf.py index 930df47d..bbfbeb38 100755 --- a/stglib/aqd/wvswad2cdf.py +++ b/stglib/aqd/wvswad2cdf.py @@ -89,7 +89,7 @@ def load_whd(metadata): WHD = pd.read_csv( whdfile, header=None, - sep="\s+", + sep=r"\s+", usecols=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20], ) @@ -150,7 +150,7 @@ def load_wad(ds): wadfile = ds.attrs["basefile"] + ".wad" print("Loading wave data from " + wadfile + "; this may take some time") # pd.read_csv is ~10x faster than np.loadtxt or np.genfromtxt - WAD = pd.read_csv(wadfile, header=None, sep="\s+").values + WAD = pd.read_csv(wadfile, header=None, sep=r"\s+").values r, c = np.shape(WAD) print(wadfile + " has " + str(r) + " rows and " + str(c) + " columns") diff --git a/stglib/argonaut.py b/stglib/argonaut.py index 8d73ee7c..4dc933c5 100644 --- a/stglib/argonaut.py +++ b/stglib/argonaut.py @@ -15,7 +15,7 @@ def read_dat_raw(filnam): df = pd.read_csv( filnam, - sep="\s+", + sep=r"\s+", parse_dates={"time": ["Year", "Month", "Day", "Hour", "Minute", "Second"]}, date_format="%Y %m %d %H %M %S", ) @@ -44,7 +44,7 @@ def rename_columns(df): def read_vel_snr_std(filbase): df = pd.read_csv( filbase + ".vel", - sep="\s+", + sep=r"\s+", header=[0, 1], parse_dates=[[1, 2, 3, 4, 5, 6]], date_format="%Y %m %d %H %M %S", @@ -92,7 +92,7 @@ def read_vel_snr_std(filbase): snr = pd.read_csv( filbase + ".snr", - sep="\s+", + sep=r"\s+", header=[0, 1], parse_dates=[[1, 2, 3, 4, 5, 6]], date_format="%Y %m %d %H %M %S", @@ -110,7 +110,7 @@ def read_vel_snr_std(filbase): std = pd.read_csv( filbase + ".std", - sep="\s+", + sep=r"\s+", header=[0, 1], parse_dates=[[1, 2, 3, 4, 5, 6]], date_format="%Y %m %d %H %M %S",