From 9eea55d889b364c9c7d5a85ffb453923f449f7e8 Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Wed, 7 Jul 2021 14:29:41 -0500 Subject: [PATCH 01/27] add in ecef2enu --- tools/RAiDER/losreader.py | 2 +- tools/RAiDER/utilFcns.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/RAiDER/losreader.py b/tools/RAiDER/losreader.py index 581eb1c1e..aa70e8eb6 100644 --- a/tools/RAiDER/losreader.py +++ b/tools/RAiDER/losreader.py @@ -98,7 +98,7 @@ def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights, zref=_ZREF): # Geo2rdr is picky about the type of height height_array = height_array.astype(np.double) - lon_start, lat_start = np.radians(360 - lon), np.radians(lat) + lon_start, lat_start = np.radians(lon), np.radians(lat) geo2rdr_obj.set_geo_coordinate(lon_start, lat_start, 1, 1, height_array) # compute the radar coordinate for each geo coordinate diff --git a/tools/RAiDER/utilFcns.py b/tools/RAiDER/utilFcns.py index 15b828625..37613d3e1 100755 --- a/tools/RAiDER/utilFcns.py +++ b/tools/RAiDER/utilFcns.py @@ -61,6 +61,21 @@ def enu2ecef(east, north, up, lat0, lon0, h0): return my_ecef +def ecef2enu(x, y, z, lat, lon, height): + '''Convert ECEF xyz to ENU''' + R = getRotMatrix(lat, lon) + inp = np.array([x,y,z]) - lla2ecef(lat, lon, height) + out = np.dot(R, inp) + return out + +def getRotMatrix(lat, lon): + '''Rotation matrix for geographic transformations''' + return np.array([ + [-sind(lon), cosd(lon), 0], + [-cosd(lon)*sind(lat), -sind(lon)*sind(lat), cosd(lat)], + [cosd(lon)*cosd(lat), sind(lon)*cosd(lat), sind(lat)] + ]) + def gdal_extents(fname): if os.path.exists(fname + '.vrt'): From f6e93cece93d8684b2541b5c0f12e738f4fb349d Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Thu, 8 Jul 2021 12:50:31 -0500 Subject: [PATCH 02/27] start some new unit tests for test_util --- test/test_util.py | 105 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 104 insertions(+), 1 deletion(-) diff --git a/test/test_util.py b/test/test_util.py index da3567614..bfabedb4d 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -12,10 +12,12 @@ from RAiDER.utilFcns import ( _least_nonzero, cosd, gdal_open, sind, writeArrayToRaster, writeResultsToHDF5, gdal_extents, - getTimeFromFile + getTimeFromFile, enu2ecef, ecef2enu, lla2ecef, ) +_R_EARTH = 6378138 + SCENARIO_DIR = os.path.join(TEST_DIR, "scenario_1") @@ -343,3 +345,104 @@ def test_read_weather_model_file(): ) assert weather_model_obj.Model() == 'ERA-5' + +def test_enu2ecef_1(): + enu = np.array([0, 0, 1]) + llh = np.array([0, 0, 0]) + ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) + assert np.allclose(ecef, np.array([_R_EARTH, 0, 0])) + +def test_enu2ecef_2(): + enu = np.array([0, 0, 1]) + llh = np.array([0, 90, 0]) + ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) + assert np.allclose(ecef, np.array([0, _R_EARTH, 0])) + +def test_enu2ecef_3(): + enu = np.array([0, 0, 1]) + llh = np.array([0, -90, 0]) + ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) + assert np.allclose(ecef, np.array([0, -_R_EARTH, 0])) + +def test_enu2ecef_4(): + enu = np.array([0, 0, 1]) + llh = np.array([90, 0, 0]) + ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) + assert np.allclose(ecef, np.array([0, 0, _R_EARTH])) + +def test_enu2ecef_5(): + enu = np.array([0, 0, 1]) + llh = np.array([-90, 0, 0]) + ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) + assert np.allclose(ecef, np.array([0, 0, -6356753.31])) + +def test_enu2ecef_6(): + enu = np.array([0, 1, 0]) + llh = np.array([0, 0, 0]) + ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) + assert np.allclose(ecef, np.array([0, 0, -6356753.31])) + + +def test_ecef2enu_1(): + enu = np.array([0, 0, 1]) + llh = np.array([0, 0, 0]) + ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) + enu_test = ecef2enu(ecef, llh[0], llh[1], llh[2]) + assert np.allclose(enu, enu_test) + +def test_ecef2enu_2(): + enu = np.array([0, 0, 1]) + llh = np.array([0, 90, 0]) + ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) + enu_test = ecef2enu(ecef, llh[0], llh[1], llh[2]) + assert np.allclose(enu, enu_test) + +def test_ecef2enu_3(): + enu = np.array([0, 0, 1]) + llh = np.array([0, -90, 0]) + ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) + enu_test = ecef2enu(ecef, llh[0], llh[1], llh[2]) + assert np.allclose(enu, enu_test) + +def test_ecef2enu_4(): + enu = np.array([0, 0, 1]) + llh = np.array([90, 0, 0]) + ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) + enu_test = ecef2enu(ecef, llh[0], llh[1], llh[2]) + assert np.allclose(enu, enu_test) + +def test_ecef2enu_5(): + enu = np.array([0, 0, 1]) + llh = np.array([-90, 0, 0]) + ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) + enu_test = ecef2enu(ecef, llh[0], llh[1], llh[2]) + assert np.allclose(enu, enu_test) + +def test_ecef2enu_6(): + enu = np.array([0, 0, 1]) + llh = np.array([0, -180, 0]) + ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) + enu_test = ecef2enu(ecef, llh[0], llh[1], llh[2]) + assert np.allclose(enu, enu_test) + +def test_ecef2enu_7(): + enu = np.array([0, 0, 1]) + llh = np.array([0, -180, 1000]) + ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) + enu_test = ecef2enu(ecef, llh[0], llh[1], llh[2]) + assert np.allclose(enu, enu_test) + +def test_ecef2enu_8(): + enu = np.array([1, 1, 0]) + llh = np.array([0, 0, 0]) + ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) + enu_test = ecef2enu(ecef, llh[0], llh[1], llh[2]) + assert np.allclose(enu, enu_test) + +def test_ecef2enu_9(): + enu = np.array([1, 1, 0]) + llh = np.array([0, 180, 0]) + ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) + enu_test = ecef2enu(ecef, llh[0], llh[1], llh[2]) + assert np.allclose(enu, enu_test) + From e7c9b6c11a5708999df69c876d82ee029d46b71a Mon Sep 17 00:00:00 2001 From: bbuzz31 Date: Tue, 6 Jul 2021 14:55:47 -0700 Subject: [PATCH 03/27] comment out extra LOS calcs (From LOS file) --- tools/RAiDER/losreader.py | 88 ++++++++++++++----- tools/RAiDER/utilFcns.py | 32 +++++-- .../geometry/cpp/classes/Geometry/Geometry.cc | 25 ++++-- 3 files changed, 107 insertions(+), 38 deletions(-) diff --git a/tools/RAiDER/losreader.py b/tools/RAiDER/losreader.py index aa70e8eb6..0c483a547 100644 --- a/tools/RAiDER/losreader.py +++ b/tools/RAiDER/losreader.py @@ -92,6 +92,12 @@ def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights, zref=_ZREF): loss = np.zeros((3, len(lats))) slant_ranges = np.zeros_like(lats) + # breakpoint() + # lons = np.where(lons>=180, lons-360, lons) # 0:360 to -180:180 + pos = lons>0 # get bools of positive + lons = lons % 360 + lons[lons == 0 & pos] == 360 # turn 0 back into 360 + for i, (lat, lon, height) in enumerate(zip(lats, lons, heights)): height_array = np.array(((height,),)) @@ -109,8 +115,14 @@ def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights, zref=_ZREF): loss[:, i] = los_x, los_y, los_z # get back the slant ranges - # slant_range = geo2rdr_obj.get_slant_range() #<- geo2rdr returns the slant range to sensor...not exactly what we want - #slant_ranges[i] = slant_range + slant_ranges[i] = geo2rdr_obj.get_slant_range() #<- geo2rdr returns the slant range to sensor...not exactly what we want + # print (slant_ranges[i]) + # //slant_range = sqrt(pow(xyz.x - st.position.x ,2) + pow(xyz.y - st.position.y, 2) + pow(xyz.z - st.position.z, 2)); + + # x -> sens + # xe -> start + + # np.sqrt((x - xe)**2 + (y-ye)**2 + (z-ze)**2) # We need LOS defined as pointing from the ground pixel to the sensor in ECEF reference frame #sp = np.stack(utilFcns.lla2ecef(lats, lons, heights),axis = -1) @@ -197,8 +209,14 @@ def read_ESA_Orbit_file(filename, time=None): vy = np.ones(numOSV) vz = np.ones(numOSV) + times = [] + for i, st in enumerate(data_block[0]): - t[i] = (datetime.datetime.strptime(st[1].text, 'UTC=%Y-%m-%dT%H:%M:%S.%f') - datetime.datetime(1970, 1, 1)).total_seconds() + t[i] = (datetime.datetime.strptime(st[1].text, 'UTC=%Y-%m-%dT%H:%M:%S.%f') + # - datetime.datetime(1970, 1, 1)).total_seconds() + - datetime.datetime(2018, 11, 11, 0, 0, 0)).total_seconds() + + times.append(datetime.datetime.strptime(st[1].text, 'UTC=%Y-%m-%dT%H:%M:%S.%f')) x[i] = float(st[4].text) y[i] = float(st[5].text) z[i] = float(st[6].text) @@ -208,10 +226,14 @@ def read_ESA_Orbit_file(filename, time=None): # Get the reference time if time is not None: - time = (time - datetime.datetime(1970, 1, 1)).total_seconds() + time = (time - datetime.datetime(2018, 11, 11, 0, 0, 0)).total_seconds() + time = time - t[0] - t = t - t[0] + t = t - t[0] + + idx = cut_orbit_file(times) + t, x, y, z, vx, vy, vz = t[idx], x[idx], y[idx], z[idx], vx[idx], vy[idx], vz[idx] # if time is not None: # mask = np.abs(t - time) < 3600 @@ -256,23 +278,24 @@ def los_to_lv(incidence, heading, lats, lons, heights, zref, ranges=None): east = utilFcns.sind(a_0) * utilFcns.cosd(a_1 + 90) north = utilFcns.sind(a_0) * utilFcns.sind(a_1 + 90) up = utilFcns.cosd(a_0) - east, north, up = np.stack((east, north, up)) - - # Pick reasonable range to top of troposphere if not provided - if ranges is None: - ranges = (zref - heights) / up - #slant_range = ranges = (zref - heights) / utilFcns.cosd(inc) - - # Scale look vectors by range - east, north, up = np.stack((east, north, up)) * ranges - - xyz = utilFcns.enu2ecef( - east.flatten(), north.flatten(), up.flatten(), lats.flatten(), - lons.flatten(), heights.flatten()) + los = np.stack((east, north, up), axis=-1) + return los - sp_xyz = utilFcns.lla2ecef(lats.flatten(), lons.flatten(), heights.flatten()) - los = np.stack(xyz, axis=-1) - np.stack(sp_xyz, axis=-1) - los = los.reshape(east.shape + (3,)) + # # Pick reasonable range to top of troposphere if not provided + # if ranges is None: + # ranges = (zref - heights) / up + # #slant_range = ranges = (zref - heights) / utilFcns.cosd(inc) + # + # # Scale look vectors by range + # east, north, up = np.stack((east, north, up)) #* ranges + # + # xyz = utilFcns.enu2ecef( + # east.flatten(), north.flatten(), up.flatten(), lats.flatten(), + # lons.flatten(), heights.flatten()) + # + # sp_xyz = utilFcns.lla2ecef(lats.flatten(), lons.flatten(), heights.flatten()) + # los = np.stack(xyz, axis=-1) - np.stack(sp_xyz, axis=-1) + # los = los.reshape(east.shape + (3,)) return los @@ -286,10 +309,14 @@ def infer_los(los, lats, lons, heights, zref, time=None): if los_type == 'sv': LOS = infer_sv(los_file, lats, lons, heights, time) + np.save('./HR_SV/LOS.npy', LOS) + print ('Saved los SV file') elif los_type == 'los': incidence, heading = [f.flatten() for f in utilFcns.gdal_open(los_file)] utilFcns.checkShapes(np.stack((incidence, heading), axis=-1), lats, lons, heights) LOS = los_to_lv(incidence, heading, lats, lons, heights, zref) + np.save('./HR_LOS/LOS.npy', LOS) + print ('Saved los LOS file') else: raise ValueError("Unsupported los type '{}'".format(los_type)) return LOS @@ -343,3 +370,22 @@ def getLookVectors(look_vecs, lats, lons, heights, zref=_ZREF, time=None): look_vecs[mask, :] = np.nan return look_vecs.reshape(in_shape + (3,)).astype(np.float64) + + +def cut_orbit_file(times, ref_time_st=None, ref_time_en=None): + """ Slice the orbit file around the reference aquisition time """ + # eventually refs will have to be gotten from SLCs which we don't require + pad = 2 # minutes + # round to nearest minute and pad + ref_time_st = utilFcns.round_time(datetime.datetime(2018, 11, 13, 23, 6, 17), 60) \ + - datetime.timedelta(minutes=pad) + ref_time_en = utilFcns.round_time(datetime.datetime(2018, 11, 13, 23, 6, 44), 60) \ + + datetime.timedelta(minutes=pad) + + idx, tim_close = [], [] + # iterate through times in orbit file, finding those within padded span + for i, time in enumerate(times): + if ref_time_st <= time <= ref_time_en: + idx.append(i) + tim_close.append(time) + return idx diff --git a/tools/RAiDER/utilFcns.py b/tools/RAiDER/utilFcns.py index 37613d3e1..4b3b3dcb6 100755 --- a/tools/RAiDER/utilFcns.py +++ b/tools/RAiDER/utilFcns.py @@ -12,8 +12,8 @@ import progressbar from RAiDER.constants import ( - Zenith, - _g0 as g0, + Zenith, + _g0 as g0, _RE as Re, R_EARTH_MAX as Rmax, R_EARTH_MIN as Rmin, @@ -269,7 +269,7 @@ def _geo_to_ht(lats, hts): # Calculate Geometric Height, h h = (hts * Re) / (g_ll / g0 * Re - hts) - # from metpy + # from metpy # return (geopotential * Re) / (g0 * Re - geopotential) return h @@ -759,9 +759,9 @@ def write2NETCDF4core(nc_outfile, dimension_dict, dataset_dict, tran, mapping_na dimensions = () var = nc_outfile.createVariable( - mapping_name, - datatype, - dimensions, + mapping_name, + datatype, + dimensions, fill_value=None ) # variable made, now add attributes @@ -834,9 +834,9 @@ def convertLons(inLons): def read_NCMR_loginInfo(filepath=None): - + from pathlib import Path - + if filepath is None: filepath = str(Path.home())+'/.ncmrlogin' @@ -856,10 +856,24 @@ def show_progress(block_num, block_size, total_size): if pbar is None: pbar = progressbar.ProgressBar(maxval=total_size) pbar.start() - + downloaded = block_num * block_size if downloaded < total_size: pbar.update(downloaded) else: pbar.finish() pbar = None + + + +def round_time(dt=None, roundTo=60): + """Round a datetime object to any time lapse in seconds + + dt : datetime.datetime object, default now. + roundTo : Closest number of seconds to round to, default 1 minute. + Author: Thierry Husson 2012 - Use it as you want but don't blame me. + """ + if dt == None : dt = datetime.now() + seconds = (dt.replace(tzinfo=None) - dt.min).seconds + rounding = (seconds+roundTo/2) // roundTo * roundTo + return dt + timedelta(0,rounding-seconds,-dt.microsecond) diff --git a/tools/bindings/geometry/cpp/classes/Geometry/Geometry.cc b/tools/bindings/geometry/cpp/classes/Geometry/Geometry.cc index a994f9d43..9b6e770ef 100644 --- a/tools/bindings/geometry/cpp/classes/Geometry/Geometry.cc +++ b/tools/bindings/geometry/cpp/classes/Geometry/Geometry.cc @@ -119,7 +119,7 @@ pixel Geo2rdr::get_radar_coordinate( Orbit &orbit, point &xyz, double t0) ii++; } double t_azimuth = t; - + double slant_range = sqrt(pow(xyz.x - st.position.x ,2) + pow(xyz.y - st.position.y, 2) + pow(xyz.z - st.position.z, 2)); return pixel(t_azimuth, slant_range); } @@ -146,7 +146,7 @@ void Geo2rdr::get_radar_coordinate( point &xyz, point &sensor_xyz, double &slant //slant_range = sqrt(pow(xyz.x - st.position.x ,2) + pow(xyz.y - st.position.y, 2) + pow(xyz.z - st.position.z, 2)); - //std::cout << setprecision(10) << " ii, dt: " << ii << " , " << dt << " , " << slant_range << std::endl; + //std::cout << setprecision(10) << " ii, dt: " << ii << " , " << dt << " , " << slant_range << std::endl; ii++; } @@ -171,16 +171,18 @@ void Geo2rdr::geo2rdr() std::cout << "geo2rdr" << std::endl; ellipsoid elp; - elp.wgs84(); + elp.wgs84(); elp.info(); int middle_stvec = nr_state_vectors/2; - double t0 = orbit.t[5]; // middle_stvec]; + // double t0 = orbit.t[5]; // middle_stvec]; //orig + // std::cout << " state vector at : " << t0 << std::endl; + double t0 = orbit.t[middle_stvec]; //orig // //statevector st = orbit.get_statevector(t0); //std::cout << " state vector at : " << t0 << std::endl; //std::cout << std::setprecision(10) << st.position.x << " , " << st.position.y << " , "<< st.position.z << std::endl; - + // double lat; @@ -194,21 +196,28 @@ void Geo2rdr::geo2rdr() los_x = new double[nr_lines*nr_pixels]; los_y = new double[nr_lines*nr_pixels]; los_z = new double[nr_lines*nr_pixels]; + + for (int line=0; line < nr_lines; line++){ for (int pixel=0; pixel Date: Wed, 7 Jul 2021 14:34:06 -0500 Subject: [PATCH 04/27] Add in ecef2enu --- tools/RAiDER/utilFcns.py | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/tools/RAiDER/utilFcns.py b/tools/RAiDER/utilFcns.py index 4b3b3dcb6..37613d3e1 100755 --- a/tools/RAiDER/utilFcns.py +++ b/tools/RAiDER/utilFcns.py @@ -12,8 +12,8 @@ import progressbar from RAiDER.constants import ( - Zenith, - _g0 as g0, + Zenith, + _g0 as g0, _RE as Re, R_EARTH_MAX as Rmax, R_EARTH_MIN as Rmin, @@ -269,7 +269,7 @@ def _geo_to_ht(lats, hts): # Calculate Geometric Height, h h = (hts * Re) / (g_ll / g0 * Re - hts) - # from metpy + # from metpy # return (geopotential * Re) / (g0 * Re - geopotential) return h @@ -759,9 +759,9 @@ def write2NETCDF4core(nc_outfile, dimension_dict, dataset_dict, tran, mapping_na dimensions = () var = nc_outfile.createVariable( - mapping_name, - datatype, - dimensions, + mapping_name, + datatype, + dimensions, fill_value=None ) # variable made, now add attributes @@ -834,9 +834,9 @@ def convertLons(inLons): def read_NCMR_loginInfo(filepath=None): - + from pathlib import Path - + if filepath is None: filepath = str(Path.home())+'/.ncmrlogin' @@ -856,24 +856,10 @@ def show_progress(block_num, block_size, total_size): if pbar is None: pbar = progressbar.ProgressBar(maxval=total_size) pbar.start() - + downloaded = block_num * block_size if downloaded < total_size: pbar.update(downloaded) else: pbar.finish() pbar = None - - - -def round_time(dt=None, roundTo=60): - """Round a datetime object to any time lapse in seconds - - dt : datetime.datetime object, default now. - roundTo : Closest number of seconds to round to, default 1 minute. - Author: Thierry Husson 2012 - Use it as you want but don't blame me. - """ - if dt == None : dt = datetime.now() - seconds = (dt.replace(tzinfo=None) - dt.min).seconds - rounding = (seconds+roundTo/2) // roundTo * roundTo - return dt + timedelta(0,rounding-seconds,-dt.microsecond) From 696c7a7d57e019ffff43a85840d7e9862e10cc94 Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Wed, 7 Jul 2021 14:35:31 -0500 Subject: [PATCH 05/27] convert ECEF unit vectors to ENU --- tools/RAiDER/losreader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/RAiDER/losreader.py b/tools/RAiDER/losreader.py index 0c483a547..3591fb287 100644 --- a/tools/RAiDER/losreader.py +++ b/tools/RAiDER/losreader.py @@ -112,7 +112,7 @@ def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights, zref=_ZREF): # get back the line of sight unit vector los_x, los_y, los_z = geo2rdr_obj.get_los() - loss[:, i] = los_x, los_y, los_z + loss[:, i] = ecef2enu(los_x, los_y, los_z, lat, lon, height) # get back the slant ranges slant_ranges[i] = geo2rdr_obj.get_slant_range() #<- geo2rdr returns the slant range to sensor...not exactly what we want From 5c06dd5bc16fbb576d95f8b0509c810ca5a85902 Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Thu, 8 Jul 2021 12:42:07 -0500 Subject: [PATCH 06/27] Fix LOS calculation and remove print statements --- tools/RAiDER/losreader.py | 408 ++++++++---------- tools/RAiDER/utilFcns.py | 16 +- .../geometry/cpp/classes/Geometry/Geometry.cc | 55 --- .../geometry/cpp/classes/Utility/Ellipsoid.h | 4 - 4 files changed, 183 insertions(+), 300 deletions(-) diff --git a/tools/RAiDER/losreader.py b/tools/RAiDER/losreader.py index 3591fb287..1a680e7b1 100644 --- a/tools/RAiDER/losreader.py +++ b/tools/RAiDER/losreader.py @@ -18,59 +18,151 @@ from RAiDER import Geo2rdr from RAiDER.constants import _ZREF, Zenith -# def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights): -# import Geo2rdr -# -# real_shape = lats.shape -# lats = lats.flatten() -# lons = lons.flatten() -# heights = heights.flatten() -# -# geo2rdr_obj = Geo2rdr.PyGeo2rdr() -# geo2rdr_obj.set_orbit(t, x, y, z, vx, vy, vz) -# -# loss = np.zeros((3, len(lats))) -# slant_ranges = np.zeros_like(lats) -# -# for i, (lat, lon, height) in enumerate(zip(lats, lons, heights)): -# height_array = np.array(((height,),)) -# -# # Geo2rdr is picky about the type of height -# height_array = height_array.astype(np.double) -# -# geo2rdr_obj.set_geo_coordinate(np.radians(lon), -# np.radians(lat), -# 1, 1, -# height_array) -# # compute the radar coordinate for each geo coordinate -# geo2rdr_obj.geo2rdr() -# -# # get back the line of sight unit vector -# los_x, los_y, los_z = geo2rdr_obj.get_los() -# loss[:, i] = los_x, los_y, los_z -# -# # get back the slant ranges -# slant_range = geo2rdr_obj.get_slant_range() -# slant_ranges[i] = slant_range -# -# los = loss * slant_ranges -# -# # Have to think about traversal order here. It's easy, though, since -# # in both orders xs come first, followed by all ys, followed by all -# # zs. -# return los.reshape((3,) + real_shape) +def getLookVectors(look_vecs, lats, lons, heights, zref=_ZREF, time=None): + ''' + If the input look vectors are specified as Zenith, compute and return the + look vectors. Otherwise, check that the look_vecs shape makes sense. + ''' + if (look_vecs is None) or (look_vecs is Zenith): + look_vecs = Zenith + else: + look_vecs = look_vecs[1] + + in_shape = lats.shape + lat = lats.flatten() + lon = lons.flatten() + hgt = heights.flatten() -def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights, zref=_ZREF): + if look_vecs is Zenith: + look_vecs = _getZenithLookVecs(lat, lon, hgt, zref=zref) + else: + look_vecs = infer_los(look_vecs, lat, lon, hgt, zref, time) + + mask = np.isnan(hgt) | np.isnan(lat) | np.isnan(lon) + look_vecs[mask, :] = np.nan + + return look_vecs.reshape(in_shape + (3,)).astype(np.float64) + + +def _getZenithLookVecs(lats, lons, heights, zref=_ZREF): + ''' + Returns look vectors when Zenith is used. + Inputs: + lats/lons/heights - Nx1 numpy arrays of points. + zref - float, integration height in meters + Outputs: + zenLookVecs - an Nx3 numpy array with the look vectors. + The vectors give the zenith ray paths for + each of the points to the top of the atmosphere. + ''' + try: + if (lats.ndim != 1) | (heights.ndim != 1) | (lons.ndim != 1): + raise RuntimeError('_getZenithLookVecs: lats/lons/heights must be 1-D numpy arrays') + except AttributeError: + raise RuntimeError('_getZenithLookVecs: lats/lons/heights must be 1-D numpy arrays') + if hasattr(zref, "__len__") | isinstance(zref, str): + raise RuntimeError('_getZenithLookVecs: zref must be a scalar') + + e = np.cos(np.radians(lats)) * np.cos(np.radians(lons)) + n = np.cos(np.radians(lats)) * np.sin(np.radians(lons)) + u = np.sin(np.radians(lats)) + zenLookVecs = (np.array((e, n, u)).T * (zref - heights)[..., np.newaxis]) + return zenLookVecs.astype(np.float64) + + +def infer_los(los_file, lats, lons, heights, zref, time=None): + ''' + Helper function to deal with various LOS files supplied + ''' + breakpoint() + try: + incidence, heading = [f.flatten() for f in utilFcns.gdal_open(los_file)] + utilFcns.checkShapes(np.stack((incidence, heading), axis=-1), lats, lons, heights) + LOS_enu = los_to_lv(incidence, heading, lats, lons, heights, zref) + LOS = utilFcns.enu2ecef(LOS_enu[...,0], LOS_enu[...,1], LOS_enu[...,2], lats, lons, heights) + + except OSError: + svs = get_sv(los_file, lats, lons, heights, time) + LOS = state_to_los(*svs, lats=lats, lons=lons, heights=heights) + + return LOS + + +def get_sv(los_file, lats, lons, heights, time=None): + """Read an LOS file.""" + # TODO: Change this to a try/except structure + _, ext = os.path.splitext(los_file) + if ext == '.txt': + svs = read_txt_file(los_file) + elif ext == '.EOF': + svs = read_ESA_Orbit_file(los_file, time) + else: + # Here's where things get complicated... Either it's a shelve + # file or the user messed up. For now we'll just try to read it + # as a shelve file, and throw whatever error that does, although + # the message might be sometimes misleading. + svs = read_shelve(los_file) + return svs + + +def los_to_lv(incidence, heading, lats, lons, heights): + ''' + Convert incidence and heading to line-of-sight vectors from the ground to the top of + the troposphere. + + Parameters + ---------- + incidence - Numpy array containing incidence angle (deg from vertical) + heading - Numpy array containing heading angle (deg clockwise from north) #TODO: check this + lats, lons, heights - Numpy arrays with WGS84 ellipsoidal target (ground pixel) locations + + Returns + ------- + LOS - * x 3 matrix of unit look vectors in local ENU reference frame + + Algorithm referenced from http://earthdef.caltech.edu/boards/4/topics/327 + ''' + a_0 = incidence + a_1 = heading + + east = utilFcns.sind(a_0) * utilFcns.cosd(a_1 + 90) + north = utilFcns.sind(a_0) * utilFcns.sind(a_1 + 90) + up = utilFcns.cosd(a_0) + + return np.stack((east, north, up), axis=-1) + + +def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights): ''' Converts information from a state vector for a satellite orbit, given in terms of position and velocity, to line-of-sight information at each (lon,lat, height) coordinate requested by the user. - *Note*: - The LOS returned should be a vector pointing from the ground pixel to the sensor, - truncating at the top of the troposphere, in an earth-centered, earth-fixed - coordinate system. + Parameters + ---------- + t, x, y, z, vx, vy, vz - time, position, and velocity in ECEF of the sensor + lats, lons, heights - Ellipsoidal (WGS84) positions of target ground pixels + + Returns + ------- + LOS - * x 3 matrix of LOS unit vectors in ECEF (*not* ENU) + + *NOTE*: + These line-of-sight vectors will NOT match ordinary LOS vectors for InSAR + because they are in an ECEF reference frame instead of a local ENU. This is done + because the construction of rays is done in ECEF rather than the local ENU. + + Example: + >>> import datetime + >>> from RAiDER.utilFcns import gdal_open + >>> import RAiDER.losreader as losr + >>> lats, lons, heights = np.array([-76.1]), np.array([36.83]), np.array([0]) + >>> time = datetime.datetime(2018,11,12,23,0,0) + >>> # download the orbit file beforehand + >>> esa_orbit_file = 'S1A_OPER_AUX_POEORB_OPOD_20181203T120749_V20181112T225942_20181114T005942.EOF' + >>> svs = losr.read_ESA_Orbit_file(esa_orbit_file, time) + >>> LOS = losr.state_to_los(*svs, lats=lats, lons=lons, heights=heights) ''' # check the inputs @@ -89,51 +181,42 @@ def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights, zref=_ZREF): geo2rdr_obj = Geo2rdr.PyGeo2rdr() geo2rdr_obj.set_orbit(t, x, y, z, vx, vy, vz) - loss = np.zeros((3, len(lats))) - slant_ranges = np.zeros_like(lats) - - # breakpoint() - # lons = np.where(lons>=180, lons-360, lons) # 0:360 to -180:180 - pos = lons>0 # get bools of positive - lons = lons % 360 - lons[lons == 0 & pos] == 360 # turn 0 back into 360 + los_ecef = np.zeros((3, len(lats))) for i, (lat, lon, height) in enumerate(zip(lats, lons, heights)): - height_array = np.array(((height,),)) - - # Geo2rdr is picky about the type of height - height_array = height_array.astype(np.double) + # Geo2rdr is picky about how the heights look + height_array = np.array(((height,),)).astype(np.double) - lon_start, lat_start = np.radians(lon), np.radians(lat) - geo2rdr_obj.set_geo_coordinate(lon_start, lat_start, 1, 1, height_array) + # Set the target pixel location + geo2rdr_obj.set_geo_coordinate(np.radians(lon), np.radians(lat), 1, 1, height_array) - # compute the radar coordinate for each geo coordinate + # compute the look vector and target-sensor range in ECEF geo2rdr_obj.geo2rdr() # get back the line of sight unit vector - los_x, los_y, los_z = geo2rdr_obj.get_los() - loss[:, i] = ecef2enu(los_x, los_y, los_z, lat, lon, height) + # LOS is defined as pointing from the ground pixel to the sensor + los_ecef[:,i] = np.squeeze(geo2rdr_obj.get_los()) - # get back the slant ranges - slant_ranges[i] = geo2rdr_obj.get_slant_range() #<- geo2rdr returns the slant range to sensor...not exactly what we want - # print (slant_ranges[i]) - # //slant_range = sqrt(pow(xyz.x - st.position.x ,2) + pow(xyz.y - st.position.y, 2) + pow(xyz.z - st.position.z, 2)); + return los_ecef.T - # x -> sens - # xe -> start - # np.sqrt((x - xe)**2 + (y-ye)**2 + (z-ze)**2) - - # We need LOS defined as pointing from the ground pixel to the sensor in ECEF reference frame - #sp = np.stack(utilFcns.lla2ecef(lats, lons, heights),axis = -1) - #pt_rng = np.linalg.norm(sp,axis=-1) - #slant_ranges = slant_ranges - pt_rng - los = -loss # * slant_ranges +def cut_orbit_file(times, ref_time_st=None, ref_time_en=None): + """ Slice the orbit file around the reference aquisition time """ + # eventually refs will have to be gotten from SLCs which we don't require + pad = 2 # minutes + # round to nearest minute and pad + ref_time_st = utilFcns.round_time(datetime.datetime(2018, 11, 13, 23, 6, 17), 60) \ + - datetime.timedelta(minutes=pad) + ref_time_en = utilFcns.round_time(datetime.datetime(2018, 11, 13, 23, 6, 44), 60) \ + + datetime.timedelta(minutes=pad) - # Have to think about traversal order here. It's easy, though, since - # in both orders xs come first, followed by all ys, followed by all - # zs. - return los.reshape(real_shape + (3,)) + idx, tim_close = [], [] + # iterate through times in orbit file, finding those within padded span + for i, time in enumerate(times): + if ref_time_st <= time <= ref_time_en: + idx.append(i) + tim_close.append(time) + return idx def read_shelve(filename): @@ -226,166 +309,13 @@ def read_ESA_Orbit_file(filename, time=None): # Get the reference time if time is not None: - time = (time - datetime.datetime(2018, 11, 11, 0, 0, 0)).total_seconds() - - time = time - t[0] - - t = t - t[0] - - idx = cut_orbit_file(times) - t, x, y, z, vx, vy, vz = t[idx], x[idx], y[idx], z[idx], vx[idx], vy[idx], vz[idx] - - # if time is not None: - # mask = np.abs(t - time) < 3600 - # t, x, y, z, vx, vy, vz = t[mask], x[mask], y[mask], z[mask], vx[mask], vy[mask], vz[mask] - - return [t, x, y, z, vx, vy, vz] - - -def infer_sv(los_file, lats, lons, heights, time=None): - """Read an LOS file.""" - # TODO: Change this to a try/except structure - _, ext = os.path.splitext(los_file) - if ext == '.txt': - svs = read_txt_file(los_file) - elif ext == '.EOF': - svs = read_ESA_Orbit_file(los_file, time) + raise RuntimeError('Need to finish this') + mask = np.abs(t - time) < 100 # Need syntax to compare seconds + t, x, y, z, vx, vy, vz = t[mask], x[mask], y[mask], z[mask], vx[mask], vy[mask], vz[mask] else: - # Here's where things get complicated... Either it's a shelve - # file or the user messed up. For now we'll just try to read it - # as a shelve file, and throw whatever error that does, although - # the message might be sometimes misleading. - svs = read_shelve(los_file) - LOSs = state_to_los(*svs, lats=lats, lons=lons, heights=heights) - return LOSs - - -def los_to_lv(incidence, heading, lats, lons, heights, zref, ranges=None): - ''' - Convert incidence and heading to line-of-sight vectors from the ground to the top of - the troposphere. + idx = cut_orbit_file(times) + t, x, y, z, vx, vy, vz = t[idx], x[idx], y[idx], z[idx], vx[idx], vy[idx], vz[idx] - *NOTE*: - LOS here is defined in an Earth-centered, earth-referenced - coordinate system as pointing from the ground pixel to the sensor, truncating at the top of - the troposphere. - - Algorithm referenced from http://earthdef.caltech.edu/boards/4/topics/327 - ''' - a_0 = incidence - a_1 = heading - - east = utilFcns.sind(a_0) * utilFcns.cosd(a_1 + 90) - north = utilFcns.sind(a_0) * utilFcns.sind(a_1 + 90) - up = utilFcns.cosd(a_0) - los = np.stack((east, north, up), axis=-1) - return los - - # # Pick reasonable range to top of troposphere if not provided - # if ranges is None: - # ranges = (zref - heights) / up - # #slant_range = ranges = (zref - heights) / utilFcns.cosd(inc) - # - # # Scale look vectors by range - # east, north, up = np.stack((east, north, up)) #* ranges - # - # xyz = utilFcns.enu2ecef( - # east.flatten(), north.flatten(), up.flatten(), lats.flatten(), - # lons.flatten(), heights.flatten()) - # - # sp_xyz = utilFcns.lla2ecef(lats.flatten(), lons.flatten(), heights.flatten()) - # los = np.stack(xyz, axis=-1) - np.stack(sp_xyz, axis=-1) - # los = los.reshape(east.shape + (3,)) - - return los - - -def infer_los(los, lats, lons, heights, zref, time=None): - ''' - Helper function to deal with various LOS files supplied - ''' - - los_type, los_file = los - - if los_type == 'sv': - LOS = infer_sv(los_file, lats, lons, heights, time) - np.save('./HR_SV/LOS.npy', LOS) - print ('Saved los SV file') - elif los_type == 'los': - incidence, heading = [f.flatten() for f in utilFcns.gdal_open(los_file)] - utilFcns.checkShapes(np.stack((incidence, heading), axis=-1), lats, lons, heights) - LOS = los_to_lv(incidence, heading, lats, lons, heights, zref) - np.save('./HR_LOS/LOS.npy', LOS) - print ('Saved los LOS file') - else: - raise ValueError("Unsupported los type '{}'".format(los_type)) - return LOS - - -def _getZenithLookVecs(lats, lons, heights, zref=_ZREF): - ''' - Returns look vectors when Zenith is used. - Inputs: - lats/lons/heights - Nx1 numpy arrays of points. - zref - float, integration height in meters - Outputs: - zenLookVecs - an Nx3 numpy array with the look vectors. - The vectors give the zenith ray paths for - each of the points to the top of the atmosphere. - ''' - try: - if (lats.ndim != 1) | (heights.ndim != 1) | (lons.ndim != 1): - raise RuntimeError('_getZenithLookVecs: lats/lons/heights must be 1-D numpy arrays') - except AttributeError: - raise RuntimeError('_getZenithLookVecs: lats/lons/heights must be 1-D numpy arrays') - if hasattr(zref, "__len__") | isinstance(zref, str): - raise RuntimeError('_getZenithLookVecs: zref must be a scalar') - - e = np.cos(np.radians(lats)) * np.cos(np.radians(lons)) - n = np.cos(np.radians(lats)) * np.sin(np.radians(lons)) - u = np.sin(np.radians(lats)) - zenLookVecs = (np.array((e, n, u)).T * (zref - heights)[..., np.newaxis]) - return zenLookVecs.astype(np.float64) - - -def getLookVectors(look_vecs, lats, lons, heights, zref=_ZREF, time=None): - ''' - If the input look vectors are specified as Zenith, compute and return the - look vectors. Otherwise, check that the look_vecs shape makes sense. - ''' - if look_vecs is None: - look_vecs = Zenith - - in_shape = lats.shape - lat = lats.flatten() - lon = lons.flatten() - hgt = heights.flatten() - - if look_vecs is Zenith: - look_vecs = _getZenithLookVecs(lat, lon, hgt, zref=zref) - else: - look_vecs = infer_los(look_vecs, lat, lon, hgt, zref, time) - - mask = np.isnan(hgt) | np.isnan(lat) | np.isnan(lon) - look_vecs[mask, :] = np.nan - - return look_vecs.reshape(in_shape + (3,)).astype(np.float64) + return [t, x, y, z, vx, vy, vz] -def cut_orbit_file(times, ref_time_st=None, ref_time_en=None): - """ Slice the orbit file around the reference aquisition time """ - # eventually refs will have to be gotten from SLCs which we don't require - pad = 2 # minutes - # round to nearest minute and pad - ref_time_st = utilFcns.round_time(datetime.datetime(2018, 11, 13, 23, 6, 17), 60) \ - - datetime.timedelta(minutes=pad) - ref_time_en = utilFcns.round_time(datetime.datetime(2018, 11, 13, 23, 6, 44), 60) \ - + datetime.timedelta(minutes=pad) - - idx, tim_close = [], [] - # iterate through times in orbit file, finding those within padded span - for i, time in enumerate(times): - if ref_time_st <= time <= ref_time_en: - idx.append(i) - tim_close.append(time) - return idx diff --git a/tools/RAiDER/utilFcns.py b/tools/RAiDER/utilFcns.py index 37613d3e1..cd0e06299 100755 --- a/tools/RAiDER/utilFcns.py +++ b/tools/RAiDER/utilFcns.py @@ -61,10 +61,10 @@ def enu2ecef(east, north, up, lat0, lon0, h0): return my_ecef -def ecef2enu(x, y, z, lat, lon, height): +def ecef2enu(xyz_ecef, lat, lon, height): '''Convert ECEF xyz to ENU''' R = getRotMatrix(lat, lon) - inp = np.array([x,y,z]) - lla2ecef(lat, lon, height) + inp = xyz_ecef# - lla2ecef(lat, lon, height) out = np.dot(R, inp) return out @@ -192,6 +192,18 @@ def writeArrayToFile(lats, lons, array, filename, noDataValue=-9999): f.write('{},{},{}\n'.format(l, L, a)) +def round_time(dt=None, roundTo=60): + """Round a datetime object to any time lapse in seconds + dt : datetime.datetime object, default now. + roundTo : Closest number of seconds to round to, default 1 minute. + Author: Thierry Husson 2012 - Use it as you want but don't blame me. + """ + if dt == None : dt = datetime.now() + seconds = (dt.replace(tzinfo=None) - dt.min).seconds + rounding = (seconds+roundTo/2) // roundTo * roundTo + return dt + timedelta(0,rounding-seconds,-dt.microsecond) + + def round_date(date, precision): # First try rounding up # Timedelta since the beginning of time diff --git a/tools/bindings/geometry/cpp/classes/Geometry/Geometry.cc b/tools/bindings/geometry/cpp/classes/Geometry/Geometry.cc index 9b6e770ef..2b4972eda 100644 --- a/tools/bindings/geometry/cpp/classes/Geometry/Geometry.cc +++ b/tools/bindings/geometry/cpp/classes/Geometry/Geometry.cc @@ -100,31 +100,6 @@ point Geo2rdr::llh2xyz(point llh, ellipsoid elip) } -pixel Geo2rdr::get_radar_coordinate( Orbit &orbit, point &xyz, double t0) -{ - double t = t0; - double dt = 1.0; - double E1, dE1; - int ii = 0; - int num_iteration = 20; - statevector st; - - while (ii < num_iteration) - { - st = orbit.get_statevector(t); - E1 = st.velocity.x*(xyz.x - st.position.x) + st.velocity.y*(xyz.y - st.position.y) + st.velocity.z*(xyz.z - st.position.z); - dE1 = -pow(st.velocity.x,2) - pow(st.velocity.y,2) - pow(st.velocity.z,2); - dt = -E1/dE1; - t = t+dt; - ii++; - } - double t_azimuth = t; - - double slant_range = sqrt(pow(xyz.x - st.position.x ,2) + pow(xyz.y - st.position.y, 2) + pow(xyz.z - st.position.z, 2)); - return pixel(t_azimuth, slant_range); -} - -//void Geo2rdr::get_radar_coordinate( Orbit &orbit, point &xyz, point &sensor_xyz, double &slant_range, double t0) void Geo2rdr::get_radar_coordinate( point &xyz, point &sensor_xyz, double &slant_range, double t0) { @@ -137,54 +112,31 @@ void Geo2rdr::get_radar_coordinate( point &xyz, point &sensor_xyz, double &slant double residual_threshold = 0.000000001; while (ii < num_iteration && fabs(dt) > residual_threshold) { - //std::cout << ii << std::endl; st = orbit.get_statevector(t); E1 = st.velocity.x*(xyz.x - st.position.x) + st.velocity.y*(xyz.y - st.position.y) + st.velocity.z*(xyz.z - st.position.z); dE1 = -pow(st.velocity.x,2) - pow(st.velocity.y,2) - pow(st.velocity.z,2); dt = -E1/dE1; t = t+dt; - - //slant_range = sqrt(pow(xyz.x - st.position.x ,2) + pow(xyz.y - st.position.y, 2) + pow(xyz.z - st.position.z, 2)); - - //std::cout << setprecision(10) << " ii, dt: " << ii << " , " << dt << " , " << slant_range << std::endl; ii++; } - //std::cout << "azimuth time : " << t << std::endl; sensor_xyz.x = st.position.x; sensor_xyz.y = st.position.y; sensor_xyz.z = st.position.z; - //double t_azimuth = t; slant_range = sqrt(pow(xyz.x - st.position.x ,2) + pow(xyz.y - st.position.y, 2) + pow(xyz.z - st.position.z, 2)); - - //double t_isce = 3118.661048; - //statevector st_i = orbit.get_statevector(t_isce); - //double rng_isce = sqrt(pow(xyz.x - st_i.position.x ,2) + pow(xyz.y - st_i.position.y, 2) + pow(xyz.z - st_i.position.z, 2)); - //std::cout << setprecision(10) << "range with isce az time: " << rng_isce << std::endl; } void Geo2rdr::geo2rdr() { - - std::cout << "geo2rdr" << std::endl; - ellipsoid elp; elp.wgs84(); elp.info(); int middle_stvec = nr_state_vectors/2; // double t0 = orbit.t[5]; // middle_stvec]; //orig - // std::cout << " state vector at : " << t0 << std::endl; double t0 = orbit.t[middle_stvec]; //orig - // - //statevector st = orbit.get_statevector(t0); - //std::cout << " state vector at : " << t0 << std::endl; - //std::cout << std::setprecision(10) << st.position.x << " , " << st.position.y << " , "<< st.position.z << std::endl; - - // - double lat; double lon; double height; @@ -204,14 +156,7 @@ void Geo2rdr::geo2rdr() lon = lon0 + pixel*delta_lon; height = heights[line][pixel];//[line*nr_pixels + pixel]; xyz = llh2xyz(point(lon, lat, height), elp); - // rdr_pixel = get_radar_coordinate(orbit, xyz, t0); - // std::cout << " new time : " << rdr_pixel.time << std::endl; - // get_radar_coordinate(orbit, xyz, this_range, t0); - get_radar_coordinate(xyz, sensor_xyz, this_range, t0); - - // azimuth_time[line*nr_pixels + pixel] = rdr_pixel.time; - range[line*nr_pixels + pixel] = this_range; los_x[line*nr_pixels + pixel] = (sensor_xyz.x - xyz.x)/this_range; los_y[line*nr_pixels + pixel] = (sensor_xyz.y - xyz.y)/this_range; diff --git a/tools/bindings/geometry/cpp/classes/Utility/Ellipsoid.h b/tools/bindings/geometry/cpp/classes/Utility/Ellipsoid.h index 3a9334765..63883ac15 100644 --- a/tools/bindings/geometry/cpp/classes/Utility/Ellipsoid.h +++ b/tools/bindings/geometry/cpp/classes/Utility/Ellipsoid.h @@ -19,10 +19,6 @@ struct ellipsoid { ellipsoid (double x, double y) {a=x;b=y;f = (a-b)/a; e2 = 2.0*f-f*f;}; void wgs84() {a=6378137.0;b=6356752.314245312;f=(a-b)/a; e2 = 2.0*f-f*f;}; void info(){ - cout << "ellipsoid:" << endl; - cout << "semi major axis a: " << a << endl; - cout << "semi minor axis b: " << b << endl; - cout << "eccentricity e2: " << e2 << endl; } }; From 175097f7442f846a7161469fb0542eb84b9e3983 Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Thu, 8 Jul 2021 13:05:48 -0500 Subject: [PATCH 07/27] add a slant range threshold for sanity checking los --- tools/RAiDER/losreader.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/RAiDER/losreader.py b/tools/RAiDER/losreader.py index 1a680e7b1..c8d31fc68 100644 --- a/tools/RAiDER/losreader.py +++ b/tools/RAiDER/losreader.py @@ -19,6 +19,9 @@ from RAiDER.constants import _ZREF, Zenith +_SLANT_RANGE_THRESH = 5e6 + + def getLookVectors(look_vecs, lats, lons, heights, zref=_ZREF, time=None): ''' If the input look vectors are specified as Zenith, compute and return the @@ -197,6 +200,16 @@ def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights): # LOS is defined as pointing from the ground pixel to the sensor los_ecef[:,i] = np.squeeze(geo2rdr_obj.get_los()) + # Sanity check for purpose of tracking problems + if geo2rdr_obj.get_slant_range() > _SLANT_RANGE_THRESH: + raise RuntimeError( + '''state_to_los: + It appears that your input datetime and/or orbit file does not correspond to the lats/lons + that you've passed. Please verify that the input datetime is the closest possible to the + acquisition times of the interferogram, and the orbit file covers the same range of time. + ''' + ) + return los_ecef.T From 78d05d8398dc6738923a0b6a47e11b69aaeaf1c2 Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Thu, 8 Jul 2021 13:06:36 -0500 Subject: [PATCH 08/27] Ensure that the geo2rdr object is deleted --- tools/RAiDER/losreader.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/RAiDER/losreader.py b/tools/RAiDER/losreader.py index c8d31fc68..4810a6ccf 100644 --- a/tools/RAiDER/losreader.py +++ b/tools/RAiDER/losreader.py @@ -209,6 +209,7 @@ def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights): acquisition times of the interferogram, and the orbit file covers the same range of time. ''' ) + del geo2rdr_obj return los_ecef.T From b7b4b4ef5051cffba1cb51f65b33dbb5d3f7e4b7 Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Thu, 8 Jul 2021 13:52:33 -0500 Subject: [PATCH 09/27] update unit tests and fix a bug --- test/test_util.py | 52 +++++++++++++++---------------------- tools/RAiDER/models/era5.py | 4 ++- 2 files changed, 24 insertions(+), 32 deletions(-) diff --git a/test/test_util.py b/test/test_util.py index bfabedb4d..d134cd628 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -368,7 +368,7 @@ def test_enu2ecef_4(): enu = np.array([0, 0, 1]) llh = np.array([90, 0, 0]) ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) - assert np.allclose(ecef, np.array([0, 0, _R_EARTH])) + assert np.allclose(ecef, np.array([0, 0, 6356753.31])) def test_enu2ecef_5(): enu = np.array([0, 0, 1]) @@ -380,69 +380,59 @@ def test_enu2ecef_6(): enu = np.array([0, 1, 0]) llh = np.array([0, 0, 0]) ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) - assert np.allclose(ecef, np.array([0, 0, -6356753.31])) + assert np.allclose(ecef, np.array([6378137, 0, 1])) def test_ecef2enu_1(): enu = np.array([0, 0, 1]) llh = np.array([0, 0, 0]) - ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) - enu_test = ecef2enu(ecef, llh[0], llh[1], llh[2]) - assert np.allclose(enu, enu_test) + enu = ecef2enu(enu, llh[0], llh[1], llh[2]) + assert np.allclose(enu, np.array([0, 1, 0])) def test_ecef2enu_2(): enu = np.array([0, 0, 1]) llh = np.array([0, 90, 0]) - ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) - enu_test = ecef2enu(ecef, llh[0], llh[1], llh[2]) - assert np.allclose(enu, enu_test) + ecef = ecef2enu(enu, llh[0], llh[1], llh[2]) + assert np.allclose(ecef, np.array([0, 1, 0])) def test_ecef2enu_3(): enu = np.array([0, 0, 1]) llh = np.array([0, -90, 0]) - ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) - enu_test = ecef2enu(ecef, llh[0], llh[1], llh[2]) - assert np.allclose(enu, enu_test) + ecef = ecef2enu(enu, llh[0], llh[1], llh[2]) + assert np.allclose(ecef, np.array([0, 1, 0])) def test_ecef2enu_4(): enu = np.array([0, 0, 1]) llh = np.array([90, 0, 0]) - ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) - enu_test = ecef2enu(ecef, llh[0], llh[1], llh[2]) - assert np.allclose(enu, enu_test) + ecef = ecef2enu(enu, llh[0], llh[1], llh[2]) + assert np.allclose(ecef, np.array([0, 0, 1])) def test_ecef2enu_5(): enu = np.array([0, 0, 1]) llh = np.array([-90, 0, 0]) - ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) - enu_test = ecef2enu(ecef, llh[0], llh[1], llh[2]) - assert np.allclose(enu, enu_test) + ecef = ecef2enu(enu, llh[0], llh[1], llh[2]) + assert np.allclose(ecef, np.array([0, 0, -1])) def test_ecef2enu_6(): - enu = np.array([0, 0, 1]) + enu = np.array([0, 0, -1]) llh = np.array([0, -180, 0]) - ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) - enu_test = ecef2enu(ecef, llh[0], llh[1], llh[2]) - assert np.allclose(enu, enu_test) + ecef = ecef2enu(enu, llh[0], llh[1], llh[2]) + assert np.allclose(ecef, np.array([0, -1, 0])) def test_ecef2enu_7(): enu = np.array([0, 0, 1]) llh = np.array([0, -180, 1000]) - ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) - enu_test = ecef2enu(ecef, llh[0], llh[1], llh[2]) - assert np.allclose(enu, enu_test) + ecef = ecef2enu(enu, llh[0], llh[1], llh[2]) + assert np.allclose(ecef, np.array([0, 1, 0])) def test_ecef2enu_8(): enu = np.array([1, 1, 0]) llh = np.array([0, 0, 0]) - ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) - enu_test = ecef2enu(ecef, llh[0], llh[1], llh[2]) - assert np.allclose(enu, enu_test) + ecef = ecef2enu(enu, llh[0], llh[1], llh[2]) + assert np.allclose(ecef, np.array([1, 0, 1])) def test_ecef2enu_9(): enu = np.array([1, 1, 0]) llh = np.array([0, 180, 0]) - ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) - enu_test = ecef2enu(ecef, llh[0], llh[1], llh[2]) - assert np.allclose(enu, enu_test) - + ecef = ecef2enu(enu, llh[0], llh[1], llh[2]) + assert np.allclose(ecef, np.array([-1, 0, -1])) diff --git a/tools/RAiDER/models/era5.py b/tools/RAiDER/models/era5.py index 1d9267a65..c6b0cacc6 100755 --- a/tools/RAiDER/models/era5.py +++ b/tools/RAiDER/models/era5.py @@ -56,5 +56,7 @@ def load_weather(self, *args, **kwargs): elif self._model_level_type == 'ml': self._load_model_levels(*self.files, *args, **kwargs) else: - raise RuntimeError('{} is not a valid model type'.format(self._model_level_type)) + raise RuntimeError( + '{} is not a valid model type'.format(self._model_level_type) + ) From 84c0ad33a7b34ed12f35e54977091f94bbda21b9 Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Mon, 12 Jul 2021 16:52:18 -0500 Subject: [PATCH 10/27] Bunch of clean up and making everything consistent --- tools/RAiDER/delay.py | 4 +- tools/RAiDER/losreader.py | 185 +++++++++++++++++++++++--------------- 2 files changed, 114 insertions(+), 75 deletions(-) diff --git a/tools/RAiDER/delay.py b/tools/RAiDER/delay.py index 6b4a0cdd1..416cd78f3 100755 --- a/tools/RAiDER/delay.py +++ b/tools/RAiDER/delay.py @@ -170,7 +170,7 @@ def tropo_delay(args): logger.debug('Beginning line-of-sight calculation') # Convert the line-of-sight inputs to look vectors - los = getLookVectors(los, lats, lons, hgts, zref) + los = getLookVectors(los[1], lats, lons, hgts, time) # write to an HDF5 file writePnts2HDF5(lats, lons, hgts, los, outName=pnts_file) @@ -286,7 +286,7 @@ def checkQueryPntsFile(pnts_file, query_shape): if os.path.exists(pnts_file): # Check whether the number of points is consistent with the new inputs with h5py.File(pnts_file, 'r') as f: - if query_shape == f['lon'].attrs['Shape']: + if query_shape == tuple(f['lon'].attrs['Shape']): write_flag = False return write_flag diff --git a/tools/RAiDER/losreader.py b/tools/RAiDER/losreader.py index 4810a6ccf..9ae9ea973 100644 --- a/tools/RAiDER/losreader.py +++ b/tools/RAiDER/losreader.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # -# Author: Jeremy Maurer, Raymond Hogenson & David Bekaert +# Author: Jeremy Maurer, Brett Buzzanga, Raymond Hogenson & David Bekaert # Copyright 2019, by the California Institute of Technology. ALL RIGHTS # RESERVED. United States Government Sponsorship acknowledged. # @@ -22,15 +22,13 @@ _SLANT_RANGE_THRESH = 5e6 -def getLookVectors(look_vecs, lats, lons, heights, zref=_ZREF, time=None): +def getLookVectors(look_vecs, lats, lons, heights, time, pad=3*3600): ''' If the input look vectors are specified as Zenith, compute and return the look vectors. Otherwise, check that the look_vecs shape makes sense. ''' if (look_vecs is None) or (look_vecs is Zenith): look_vecs = Zenith - else: - look_vecs = look_vecs[1] in_shape = lats.shape lat = lats.flatten() @@ -38,9 +36,9 @@ def getLookVectors(look_vecs, lats, lons, heights, zref=_ZREF, time=None): hgt = heights.flatten() if look_vecs is Zenith: - look_vecs = _getZenithLookVecs(lat, lon, hgt, zref=zref) + look_vecs = _getZenithLookVecs(lat, lon, hgt) else: - look_vecs = infer_los(look_vecs, lat, lon, hgt, zref, time) + look_vecs = infer_los(look_vecs, lat, lon, hgt, time, pad) mask = np.isnan(hgt) | np.isnan(lat) | np.isnan(lon) look_vecs[mask, :] = np.nan @@ -48,64 +46,94 @@ def getLookVectors(look_vecs, lats, lons, heights, zref=_ZREF, time=None): return look_vecs.reshape(in_shape + (3,)).astype(np.float64) -def _getZenithLookVecs(lats, lons, heights, zref=_ZREF): +def _getZenithLookVecs(lats, lons, heights): ''' Returns look vectors when Zenith is used. - Inputs: - lats/lons/heights - Nx1 numpy arrays of points. - zref - float, integration height in meters - Outputs: - zenLookVecs - an Nx3 numpy array with the look vectors. - The vectors give the zenith ray paths for - each of the points to the top of the atmosphere. + + Parameters + ---------- + lats/lons/heights - Nx1 numpy arrays of points. + + Returns + ------- + zenLookVecs - an Nx3 numpy array with the unit look vectors in an ECEF + reference frame. ''' try: if (lats.ndim != 1) | (heights.ndim != 1) | (lons.ndim != 1): - raise RuntimeError('_getZenithLookVecs: lats/lons/heights must be 1-D numpy arrays') + raise ValueError( + '_getZenithLookVecs: lats/lons/heights must be 1-D numpy arrays' + ) except AttributeError: - raise RuntimeError('_getZenithLookVecs: lats/lons/heights must be 1-D numpy arrays') - if hasattr(zref, "__len__") | isinstance(zref, str): - raise RuntimeError('_getZenithLookVecs: zref must be a scalar') + raise ValueError( + '_getZenithLookVecs: lats/lons/heights must be 1-D numpy arrays' + ) e = np.cos(np.radians(lats)) * np.cos(np.radians(lons)) n = np.cos(np.radians(lats)) * np.sin(np.radians(lons)) u = np.sin(np.radians(lats)) - zenLookVecs = (np.array((e, n, u)).T * (zref - heights)[..., np.newaxis]) - return zenLookVecs.astype(np.float64) + + ecef = utilFcns.enu2ecef(e, n, u, lats, lons, heights) + return ecef.astype(np.float64) -def infer_los(los_file, lats, lons, heights, zref, time=None): +def infer_los(los_file, lats, lons, heights, time, pad=3*3600): ''' Helper function to deal with various LOS files supplied ''' - breakpoint() + # Assume that the user passed a line-of-sight file try: incidence, heading = [f.flatten() for f in utilFcns.gdal_open(los_file)] utilFcns.checkShapes(np.stack((incidence, heading), axis=-1), lats, lons, heights) - LOS_enu = los_to_lv(incidence, heading, lats, lons, heights, zref) + LOS_enu = los_to_lv(incidence, heading, lats, lons, heights) LOS = utilFcns.enu2ecef(LOS_enu[...,0], LOS_enu[...,1], LOS_enu[...,2], lats, lons, heights) + # if that doesn't work, try parsing as a statevector (orbit) file except OSError: - svs = get_sv(los_file, lats, lons, heights, time) + svs = get_sv(los_file, time, pad) LOS = state_to_los(*svs, lats=lats, lons=lons, heights=heights) + # Otherwise, throw an error + except: + raise ValueError('infer_los: I cannot parse the file {}'.format(los_file)) + return LOS -def get_sv(los_file, lats, lons, heights, time=None): - """Read an LOS file.""" - # TODO: Change this to a try/except structure - _, ext = os.path.splitext(los_file) - if ext == '.txt': +def get_sv(los_file, ref_time, pad=3*3600): + """ + Read an LOS file. + + Parameters + ---------- + los_file: str - user-passed file containing either look + vectors or statevectors for the sensor + ref_time: python datetime - User-requested datetime; if not encompassed + by the orbit times will raise a ValueError + pad: int - number of seconds to keep around the + requested time + + Returns + ------- + svs: 7 x 1 list of Nt x 1 ndarrays - the times, x/y/z positions and + velocities of the sensor for the given + window around the reference time + """ + try: svs = read_txt_file(los_file) - elif ext == '.EOF': - svs = read_ESA_Orbit_file(los_file, time) - else: - # Here's where things get complicated... Either it's a shelve - # file or the user messed up. For now we'll just try to read it - # as a shelve file, and throw whatever error that does, although - # the message might be sometimes misleading. - svs = read_shelve(los_file) + except ValueError: + try: + svs = read_ESA_Orbit_file(los_file, ref_time) + except: + try: + svs = read_shelve(los_file) + except: + raise ValueError( + 'get_sv: I cannot parse the statevector file {}'.format(los_file) + ) + + idx = cut_times(svs[0], pad=pad) + svs = [d[idx] for d in svs] return svs @@ -170,7 +198,10 @@ def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights): # check the inputs if t.size < 4: - raise RuntimeError('state_to_los: At least 4 state vectors are required for orbit interpolation') + raise RuntimeError( + 'state_to_los: At least 4 state vectors are required' + ' for orbit interpolation' + ) if t.shape != x.shape: raise RuntimeError('state_to_los: t and x must be the same size') if lats.shape != lons.shape: @@ -203,10 +234,13 @@ def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights): # Sanity check for purpose of tracking problems if geo2rdr_obj.get_slant_range() > _SLANT_RANGE_THRESH: raise RuntimeError( - '''state_to_los: - It appears that your input datetime and/or orbit file does not correspond to the lats/lons - that you've passed. Please verify that the input datetime is the closest possible to the - acquisition times of the interferogram, and the orbit file covers the same range of time. + ''' + state_to_los: + It appears that your input datetime and/or orbit file does not + correspond to the lats/lons that you've passed. Please verify + that the input datetime is the closest possible to the + acquisition times of the interferogram, and the orbit file covers + the same range of time. ''' ) del geo2rdr_obj @@ -214,23 +248,23 @@ def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights): return los_ecef.T -def cut_orbit_file(times, ref_time_st=None, ref_time_en=None): - """ Slice the orbit file around the reference aquisition time """ - # eventually refs will have to be gotten from SLCs which we don't require - pad = 2 # minutes - # round to nearest minute and pad - ref_time_st = utilFcns.round_time(datetime.datetime(2018, 11, 13, 23, 6, 17), 60) \ - - datetime.timedelta(minutes=pad) - ref_time_en = utilFcns.round_time(datetime.datetime(2018, 11, 13, 23, 6, 44), 60) \ - + datetime.timedelta(minutes=pad) +def cut_times(times, pad=3600*3): + """ + Slice the orbit file around the reference aquisition time. This is done + by default using a three-hour window, which for Sentinel-1 empirically + works out to be roughly the largest window allowed by the orbit time. - idx, tim_close = [], [] - # iterate through times in orbit file, finding those within padded span - for i, time in enumerate(times): - if ref_time_st <= time <= ref_time_en: - idx.append(i) - tim_close.append(time) - return idx + Parameters + ---------- + times: Nt x 1 ndarray - Vector of orbit times as seconds since the + user-requested time + pad: int - integer time in seconds to use as padding + + Returns + ------- + idx: Nt x 1 logical ndarray - a mask of times within the padded request time. + """ + return np.abs(times) < pad def read_shelve(filename): @@ -289,9 +323,22 @@ def read_txt_file(filename): return [np.array(a) for a in [t, x, y, z, vx, vy, vz]] -def read_ESA_Orbit_file(filename, time=None): +def read_ESA_Orbit_file(filename, ref_time): ''' Read orbit data from an orbit file supplied by ESA + + Parameters + ---------- + filename: str - string of the orbit filename + ref_time: python datetime - user requested python datetime + + Returns + ------- + t: Nt x 1 ndarray - a numpy vector with Nt elements containing time + in seconds since the reference time, within "pad" + seconds of the reference time + x, y, z: Nt x 1 ndarrays - x/y/z positions of the sensor at the times t + vx, vy, vz: Nt x 1 ndarrays - x/y/z velocities of the sensor at the times t ''' tree = ET.parse(filename) root = tree.getroot() @@ -307,13 +354,14 @@ def read_ESA_Orbit_file(filename, time=None): vz = np.ones(numOSV) times = [] - for i, st in enumerate(data_block[0]): - t[i] = (datetime.datetime.strptime(st[1].text, 'UTC=%Y-%m-%dT%H:%M:%S.%f') - # - datetime.datetime(1970, 1, 1)).total_seconds() - - datetime.datetime(2018, 11, 11, 0, 0, 0)).total_seconds() + t[i] = ( + datetime.datetime.strptime( + st[1].text, + 'UTC=%Y-%m-%dT%H:%M:%S.%f' + ) - ref_time + ).total_seconds() - times.append(datetime.datetime.strptime(st[1].text, 'UTC=%Y-%m-%dT%H:%M:%S.%f')) x[i] = float(st[4].text) y[i] = float(st[5].text) z[i] = float(st[6].text) @@ -321,15 +369,6 @@ def read_ESA_Orbit_file(filename, time=None): vy[i] = float(st[8].text) vz[i] = float(st[9].text) - # Get the reference time - if time is not None: - raise RuntimeError('Need to finish this') - mask = np.abs(t - time) < 100 # Need syntax to compare seconds - t, x, y, z, vx, vy, vz = t[mask], x[mask], y[mask], z[mask], vx[mask], vy[mask], vz[mask] - else: - idx = cut_orbit_file(times) - t, x, y, z, vx, vy, vz = t[idx], x[idx], y[idx], z[idx], vx[idx], vy[idx], vz[idx] - return [t, x, y, z, vx, vy, vz] From 81ae34e858597dfac8b0596c28d982a7acb79428 Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Mon, 12 Jul 2021 22:18:17 -0500 Subject: [PATCH 11/27] fix a couple bugs --- tools/RAiDER/delay.py | 2 +- tools/RAiDER/losreader.py | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/tools/RAiDER/delay.py b/tools/RAiDER/delay.py index 416cd78f3..fe4f3d502 100755 --- a/tools/RAiDER/delay.py +++ b/tools/RAiDER/delay.py @@ -170,7 +170,7 @@ def tropo_delay(args): logger.debug('Beginning line-of-sight calculation') # Convert the line-of-sight inputs to look vectors - los = getLookVectors(los[1], lats, lons, hgts, time) + los = getLookVectors(los, lats, lons, hgts, time) # write to an HDF5 file writePnts2HDF5(lats, lons, hgts, los, outName=pnts_file) diff --git a/tools/RAiDER/losreader.py b/tools/RAiDER/losreader.py index 9ae9ea973..2a71e8290 100644 --- a/tools/RAiDER/losreader.py +++ b/tools/RAiDER/losreader.py @@ -29,6 +29,8 @@ def getLookVectors(look_vecs, lats, lons, heights, time, pad=3*3600): ''' if (look_vecs is None) or (look_vecs is Zenith): look_vecs = Zenith + else: + look_vecs = look_vecs[1] in_shape = lats.shape lat = lats.flatten() @@ -73,7 +75,7 @@ def _getZenithLookVecs(lats, lons, heights): n = np.cos(np.radians(lats)) * np.sin(np.radians(lons)) u = np.sin(np.radians(lats)) - ecef = utilFcns.enu2ecef(e, n, u, lats, lons, heights) + ecef = utilFcns.enu2ecef(e, n, u, lats, lons, heights).T return ecef.astype(np.float64) @@ -84,9 +86,24 @@ def infer_los(los_file, lats, lons, heights, time, pad=3*3600): # Assume that the user passed a line-of-sight file try: incidence, heading = [f.flatten() for f in utilFcns.gdal_open(los_file)] - utilFcns.checkShapes(np.stack((incidence, heading), axis=-1), lats, lons, heights) + utilFcns.checkShapes( + np.stack( + (incidence, heading), + axis=-1 + ), + lats, + lons, + heights + ) LOS_enu = los_to_lv(incidence, heading, lats, lons, heights) - LOS = utilFcns.enu2ecef(LOS_enu[...,0], LOS_enu[...,1], LOS_enu[...,2], lats, lons, heights) + LOS = utilFcns.enu2ecef( + LOS_enu[...,0], + LOS_enu[...,1], + LOS_enu[...,2], + lats, + lons, + heights + ) # if that doesn't work, try parsing as a statevector (orbit) file except OSError: From ac31bdcea1e167ed99bfbffec36aa0e5c04836c2 Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Thu, 15 Jul 2021 12:25:46 -0500 Subject: [PATCH 12/27] Add unit tests and docstrings --- test/test_losreader.py | 190 ++++++++++++++++++++++++++++++++++++++ test/test_scenario_1.py | 2 +- test/test_scenario_2.py | 2 +- tools/RAiDER/delay.py | 1 + tools/RAiDER/losreader.py | 43 ++++++--- 5 files changed, 222 insertions(+), 16 deletions(-) create mode 100644 test/test_losreader.py diff --git a/test/test_losreader.py b/test/test_losreader.py new file mode 100644 index 000000000..59103d565 --- /dev/null +++ b/test/test_losreader.py @@ -0,0 +1,190 @@ +import datetime +import os +import pytest +from test import DATA_DIR + +import numpy as np + +from RAiDER.losreader import ( + read_ESA_Orbit_file, + read_txt_file, + cut_times, + los_to_lv, + get_sv, +) + +@pytest.fixture +def svs(): + ref_time = datetime.datetime(2018, 11, 12, 23, 0, 42) + T = [ + datetime.datetime(2018, 11, 12, 23, 0, 2), + datetime.datetime(2018, 11, 12, 23, 0, 12), + datetime.datetime(2018, 11, 12, 23, 0, 22), + datetime.datetime(2018, 11, 12, 23, 0, 32), + datetime.datetime(2018, 11, 12, 23, 0, 42), + datetime.datetime(2018, 11, 12, 23, 0, 52), + datetime.datetime(2018, 11, 12, 23, 1, 2), + datetime.datetime(2018, 11, 12, 23, 1, 12), + ] + tr = np.array([(t - ref_time).total_seconds() for t in T]) + x = np.array([ + -2064965.285362, + -2056228.553736, + -2047224.526705, + -2037955.293282, + -2028422.977002, + -2018629.735564, + -2008577.760461, + -1998269.276601, + ]) + y = np.array([ + 6434865.494987, + 6460407.492520, + 6485212.031660, + 6509275.946120, + 6532596.156540, + 6555169.670917, + 6576993.585012, + 6598065.082739, + ]) + z = np.array([ + 2090670.967443, + 2019650.417312, + 1948401.684024, + 1876932.818066, + 1805251.894958, + 1733367.014327, + 1661286.298987, + 1589017.893976, + ]) + vx = np.array([ + 860.239634, + 887.072466, + 913.698134, + 940.113169, + 966.314136, + 992.297636, + 1018.060311, + 1043.598837, + ]) + vy = np.array([ + 2590.964968, + 2517.380329, + 2443.474728, + 2369.256838, + 2294.735374, + 2219.919093, + 2144.816789, + 2069.437298, + ]) + vz = np.array([ + -7090.378144, + -7113.598127, + -7136.014344, + -7157.624244, + -7178.425371, + -7198.415359, + -7217.591940, + -7235.952940, + ]) + return [tr, x, y, z, vx, vy, vz], ref_time + + +def test_read_ESA_Orbit_file(svs): + true_svs, ref_time = svs + filename = os.path.join(DATA_DIR, 'S1_orbit_example.EOF') + svs = read_ESA_Orbit_file(filename, ref_time) + assert [np.allclose(s, ts) for s, ts in zip(svs, true_svs)] + +def test_read_txt_file(svs): + true_svs, ref_time = svs + filename = os.path.join(DATA_DIR, 'S1_sv_file.txt') + svs = read_txt_file(filename) + assert [np.allclose(s, ts) for s, ts in zip(svs, true_svs)] + +def test_get_sv_1(svs): + true_svs, ref_time = svs + filename = os.path.join(DATA_DIR, 'S1_orbit_example.EOF') + svs = get_sv(filename, ref_time) + assert [np.allclose(s, ts) for s, ts in zip(svs, true_svs)] + +def test_get_sv_2(svs): + true_svs, ref_time = svs + filename = os.path.join(DATA_DIR, 'S1_sv_file.txt') + svs = get_sv(filename, ref_time) + assert [np.allclose(s, ts) for s, ts in zip(svs, true_svs)] + +def test_get_sv_3(svs): + true_svs, ref_time = svs + filename = os.path.join(DATA_DIR, 'geom', 'warpedDEM.dem') + with pytest.raises(ValueError): + get_sv(filename, ref_time) + +def test_get_sv_4(svs): + true_svs, ref_time = svs + filename = os.path.join(DATA_DIR, 'no_exist.txt') + with pytest.raises(FileNotFoundError): + get_sv(filename, ref_time) + +def test_cut_times(svs): + true_svs, ref_time = svs + assert len(true_svs[0][cut_times(true_svs[0])]) == len(true_svs[0]) + +def test_cut_times_2(svs): + true_svs, ref_time = svs + assert len(true_svs[0][cut_times(true_svs[0], pad=5)]) == 1 + +def test_cut_times_3(svs): + true_svs, ref_time = svs + assert len(true_svs[0][cut_times(true_svs[0], pad=15)]) == 3 + +def test_cut_times_4(svs): + true_svs, ref_time = svs + + assert len(true_svs[0][cut_times(true_svs[0], pad=400)]) == len(true_svs[0]) + +def test_los_to_lv(): + with pytest.raises(ValueError): + los_to_lv(-10, 0) + +def test_los_to_lv_2(): + assert np.allclose( + los_to_lv(0, 0), + np.array([0, 0, 1]) + ) + +def test_los_to_lv_3(): + assert np.allclose( + los_to_lv(0, -180), + np.array([0, 0, 1]) + ) + +def test_los_to_lv_3b(): + assert np.allclose( + los_to_lv(0, 18), + np.array([0, 0, 1]) + ) + +def test_los_to_lv_3c(): + assert np.allclose( + los_to_lv(0, -18), + np.array([0, 0, 1]) + ) + +def test_los_to_lv_4(): + assert np.allclose( + los_to_lv(35, 0), + np.array([0, np.sin(np.radians(35)), np.cos(np.radians(35))]) + ) + +def test_los_to_lv_5(): + assert np.allclose( + los_to_lv(35, 180), + np.array([0, -np.sin(np.radians(35)), np.cos(np.radians(35))]) + ) + +def test_los_to_lv_6(): + assert np.allclose( + los_to_lv(35, 90), + np.array([-np.sin(np.radians(35)), 0, np.cos(np.radians(35))]) + ) diff --git a/test/test_scenario_1.py b/test/test_scenario_1.py index 0386b04aa..394e667c6 100755 --- a/test/test_scenario_1.py +++ b/test/test_scenario_1.py @@ -5,7 +5,7 @@ import numpy as np -from test import DATA_DIR, TEST_DIR, pushd +from test import TEST_DIR, pushd from RAiDER.constants import Zenith diff --git a/test/test_scenario_2.py b/test/test_scenario_2.py index 3fb688340..3b786de0d 100644 --- a/test/test_scenario_2.py +++ b/test/test_scenario_2.py @@ -5,7 +5,7 @@ import pandas as pd import pytest from shutil import copyfile -from test import DATA_DIR, TEST_DIR, pushd +from test import TEST_DIR, pushd from RAiDER.constants import Zenith from RAiDER.delay import tropo_delay diff --git a/tools/RAiDER/delay.py b/tools/RAiDER/delay.py index fe4f3d502..302288496 100755 --- a/tools/RAiDER/delay.py +++ b/tools/RAiDER/delay.py @@ -42,6 +42,7 @@ def computeDelay( logger.debug('Reference integration step is {:1.1f} m'.format(step)) # If weather model nodes only are desired, the calculation is very quick + breakpoint() if useWeatherNodes: # Get the weather model data with Dataset(weather_model_file_name, mode='r') as f: diff --git a/tools/RAiDER/losreader.py b/tools/RAiDER/losreader.py index 2a71e8290..81f40a0f3 100644 --- a/tools/RAiDER/losreader.py +++ b/tools/RAiDER/losreader.py @@ -37,6 +37,7 @@ def getLookVectors(look_vecs, lats, lons, heights, time, pad=3*3600): lon = lons.flatten() hgt = heights.flatten() + breakpoint() if look_vecs is Zenith: look_vecs = _getZenithLookVecs(lat, lon, hgt) else: @@ -95,7 +96,7 @@ def infer_los(los_file, lats, lons, heights, time, pad=3*3600): lons, heights ) - LOS_enu = los_to_lv(incidence, heading, lats, lons, heights) + LOS_enu = los_to_lv(incidence, heading) LOS = utilFcns.enu2ecef( LOS_enu[...,0], LOS_enu[...,1], @@ -154,29 +155,29 @@ def get_sv(los_file, ref_time, pad=3*3600): return svs -def los_to_lv(incidence, heading, lats, lons, heights): +def los_to_lv(incidence, heading): ''' Convert incidence and heading to line-of-sight vectors from the ground to the top of the troposphere. Parameters ---------- - incidence - Numpy array containing incidence angle (deg from vertical) - heading - Numpy array containing heading angle (deg clockwise from north) #TODO: check this - lats, lons, heights - Numpy arrays with WGS84 ellipsoidal target (ground pixel) locations + incidence: ndarray - incidence angle in deg from vertical + heading: ndarray - heading angle in deg clockwise from north + lats/lons/heights: ndarray - WGS84 ellipsoidal target (ground pixel) locations Returns ------- - LOS - * x 3 matrix of unit look vectors in local ENU reference frame + LOS: ndarray - (input_shape) x 3 array of unit look vectors in local ENU Algorithm referenced from http://earthdef.caltech.edu/boards/4/topics/327 ''' - a_0 = incidence - a_1 = heading + if np.any(incidence < 0): + raise ValueError('los_to_lv: Incidence angle cannot be less than 0') - east = utilFcns.sind(a_0) * utilFcns.cosd(a_1 + 90) - north = utilFcns.sind(a_0) * utilFcns.sind(a_1 + 90) - up = utilFcns.cosd(a_0) + east = utilFcns.sind(incidence) * utilFcns.cosd(heading + 90) + north = utilFcns.sind(incidence) * utilFcns.sind(heading + 90) + up = utilFcns.cosd(incidence) return np.stack((east, north, up), axis=-1) @@ -285,9 +286,7 @@ def cut_times(times, pad=3600*3): def read_shelve(filename): - ''' - TODO: docstring - ''' + #TODO: docstring and unit tests with shelve.open(filename, 'r') as db: obj = db['frame'] @@ -314,6 +313,22 @@ def read_shelve(filename): def read_txt_file(filename): + ''' + Read a 7-column text file containing orbit statevectors. Time + should be denoted as integer time in seconds since the reference + epoch (user-requested time). + + Parameters + ---------- + filename: str - user-supplied space-delimited text file with no header + containing orbital statevectors as 7 columns: + - time in seconds since the user-supplied epoch + - x / y / z locations in ECEF cartesian coordinates + - vx / vy / vz velocities in m/s in ECEF coordinates + Returns + svs: list - a length-7 list of numpy vectors containing the above + variables + ''' t = list() x = list() y = list() From 8549bc33993b1755e56649a1bbfb7f05ed2aa061 Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Thu, 15 Jul 2021 13:24:46 -0500 Subject: [PATCH 13/27] refactor losreader to be cleaner, add unit tests --- test/test_losreader.py | 56 ++++++++++++++--- tools/RAiDER/delay.py | 1 - tools/RAiDER/losreader.py | 124 +++++++++++++++++++------------------- 3 files changed, 108 insertions(+), 73 deletions(-) diff --git a/test/test_losreader.py b/test/test_losreader.py index 59103d565..9f0bf3889 100644 --- a/test/test_losreader.py +++ b/test/test_losreader.py @@ -9,8 +9,9 @@ read_ESA_Orbit_file, read_txt_file, cut_times, - los_to_lv, + inc_hd_to_enu, get_sv, + getZenithLookVecs, ) @pytest.fixture @@ -145,46 +146,83 @@ def test_cut_times_4(svs): def test_los_to_lv(): with pytest.raises(ValueError): - los_to_lv(-10, 0) + inc_hd_to_enu(-10, 0) def test_los_to_lv_2(): assert np.allclose( - los_to_lv(0, 0), + inc_hd_to_enu(0, 0), np.array([0, 0, 1]) ) def test_los_to_lv_3(): assert np.allclose( - los_to_lv(0, -180), + inc_hd_to_enu(0, -180), np.array([0, 0, 1]) ) def test_los_to_lv_3b(): assert np.allclose( - los_to_lv(0, 18), + inc_hd_to_enu(0, 18), np.array([0, 0, 1]) ) def test_los_to_lv_3c(): assert np.allclose( - los_to_lv(0, -18), + inc_hd_to_enu(0, -18), np.array([0, 0, 1]) ) def test_los_to_lv_4(): assert np.allclose( - los_to_lv(35, 0), + inc_hd_to_enu(35, 0), np.array([0, np.sin(np.radians(35)), np.cos(np.radians(35))]) ) def test_los_to_lv_5(): assert np.allclose( - los_to_lv(35, 180), + inc_hd_to_enu(35, 180), np.array([0, -np.sin(np.radians(35)), np.cos(np.radians(35))]) ) def test_los_to_lv_6(): assert np.allclose( - los_to_lv(35, 90), + inc_hd_to_enu(35, 90), np.array([-np.sin(np.radians(35)), 0, np.cos(np.radians(35))]) ) + +def test_zenith_1(): + assert np.allclose( + getZenithLookVecs(np.array([0]), np.array([0]), np.array([0])), + np.array([1, 0, 0]) + ) + +def test_zenith_2(): + assert np.allclose( + getZenithLookVecs(np.array([90]), np.array([0]), np.array([0])), + np.array([0, 0, 1]) + ) + +def test_zenith_3(): + assert np.allclose( + getZenithLookVecs(np.array([-90]), np.array([0]), np.array([0])), + np.array([0, 0, -1]) + ) + +def test_zenith_4(): + assert np.allclose( + getZenithLookVecs(np.array([0]), np.array([180]), np.array([0])), + np.array([-1, 0, 0]) + ) + +def test_zenith_5(): + assert np.allclose( + getZenithLookVecs(np.array([0]), np.array([90]), np.array([0])), + np.array([0, 1, 0]) + ) + +def test_zenith_6(): + assert np.allclose( + getZenithLookVecs(np.array([0]), np.array([0]), np.array([1000])), + np.array([1, 0, 0]) + ) + diff --git a/tools/RAiDER/delay.py b/tools/RAiDER/delay.py index 302288496..fe4f3d502 100755 --- a/tools/RAiDER/delay.py +++ b/tools/RAiDER/delay.py @@ -42,7 +42,6 @@ def computeDelay( logger.debug('Reference integration step is {:1.1f} m'.format(step)) # If weather model nodes only are desired, the calculation is very quick - breakpoint() if useWeatherNodes: # Get the weather model data with Dataset(weather_model_file_name, mode='r') as f: diff --git a/tools/RAiDER/losreader.py b/tools/RAiDER/losreader.py index 81f40a0f3..0ccc6e716 100644 --- a/tools/RAiDER/losreader.py +++ b/tools/RAiDER/losreader.py @@ -22,10 +22,39 @@ _SLANT_RANGE_THRESH = 5e6 -def getLookVectors(look_vecs, lats, lons, heights, time, pad=3*3600): +def getLookVectors(look_vecs, lats, lons, heights, time=None, pad=3*3600): ''' - If the input look vectors are specified as Zenith, compute and return the - look vectors. Otherwise, check that the look_vecs shape makes sense. + Get unit look vectors pointing from the ground (target) pixels to the sensor, + or to Zenith. Can be accomplished using an ISCE-style 2-band LOS file or a + file containing orbital statevectors. + + Parameters + ---------- + look_vecs: LookVector object or tuple - Either a Zenith object or a tuple, + with the second element containing + the name of either a line-of-sight + file or orbital statevectors file + lats/lons/heights: ndarray - WGS-84 coordinates of the target pixels + time: python datetime - user-requested query time. Must be + compatible with the orbit file passed. + Only required for a statevector file. + pad: int - integer number of seconds to pad around + the user-specified time; default 3 hours + Only required for a statevector file. + + Returns + ------- + look_vecs: ndarray - an x 3 array of unit look vectors, defined in an + Earth-centered, earth-fixed reference frame (ECEF). Convention is + vectors point from the target pixel to the sensor. + + Example: + -------- + >>> from RAiDER.constants import Zenith + >>> from RAiDER.losreader import getLookVectors + >>> import numpy as np + >>> getLookVectors(Zenith, np.array([0]), np.array([0]), np.array([0])) + >>> # array([[1, 0, 0]]) ''' if (look_vecs is None) or (look_vecs is Zenith): look_vecs = Zenith @@ -37,11 +66,30 @@ def getLookVectors(look_vecs, lats, lons, heights, time, pad=3*3600): lon = lons.flatten() hgt = heights.flatten() - breakpoint() if look_vecs is Zenith: - look_vecs = _getZenithLookVecs(lat, lon, hgt) + look_vecs = getZenithLookVecs(lat, lon, hgt) else: - look_vecs = infer_los(look_vecs, lat, lon, hgt, time, pad) + try: + LOS_enu = inc_hd_to_enu(*utilFcns.gdal_open(los_file)) + look_vecs = utilFcns.enu2ecef( + LOS_enu[...,0], + LOS_enu[...,1], + LOS_enu[...,2], + lats, + lons, + heights + ) + + # if that doesn't work, try parsing as a statevector (orbit) file + except OSError: + svs = get_sv(los_file, time, pad) + look_vecs = state_to_los(*svs, lats=lats, lons=lons, heights=heights) + + # Otherwise, throw an error + except: + raise ValueError( + 'getLookVectors: I cannot parse the file {}'.format(los_file) + ) mask = np.isnan(hgt) | np.isnan(lat) | np.isnan(lon) look_vecs[mask, :] = np.nan @@ -49,78 +97,28 @@ def getLookVectors(look_vecs, lats, lons, heights, time, pad=3*3600): return look_vecs.reshape(in_shape + (3,)).astype(np.float64) -def _getZenithLookVecs(lats, lons, heights): +def getZenithLookVecs(lats, lons, heights): ''' Returns look vectors when Zenith is used. Parameters ---------- - lats/lons/heights - Nx1 numpy arrays of points. + lats/lons/heights: ndarray - Numpy arrays containing WGS-84 target locations Returns ------- - zenLookVecs - an Nx3 numpy array with the unit look vectors in an ECEF - reference frame. + zenLookVecs: ndarray - (in_shape) x 3 unit look vectors in an ECEF reference frame ''' - try: - if (lats.ndim != 1) | (heights.ndim != 1) | (lons.ndim != 1): - raise ValueError( - '_getZenithLookVecs: lats/lons/heights must be 1-D numpy arrays' - ) - except AttributeError: - raise ValueError( - '_getZenithLookVecs: lats/lons/heights must be 1-D numpy arrays' - ) - e = np.cos(np.radians(lats)) * np.cos(np.radians(lons)) n = np.cos(np.radians(lats)) * np.sin(np.radians(lons)) u = np.sin(np.radians(lats)) - ecef = utilFcns.enu2ecef(e, n, u, lats, lons, heights).T - return ecef.astype(np.float64) - - -def infer_los(los_file, lats, lons, heights, time, pad=3*3600): - ''' - Helper function to deal with various LOS files supplied - ''' - # Assume that the user passed a line-of-sight file - try: - incidence, heading = [f.flatten() for f in utilFcns.gdal_open(los_file)] - utilFcns.checkShapes( - np.stack( - (incidence, heading), - axis=-1 - ), - lats, - lons, - heights - ) - LOS_enu = los_to_lv(incidence, heading) - LOS = utilFcns.enu2ecef( - LOS_enu[...,0], - LOS_enu[...,1], - LOS_enu[...,2], - lats, - lons, - heights - ) - - # if that doesn't work, try parsing as a statevector (orbit) file - except OSError: - svs = get_sv(los_file, time, pad) - LOS = state_to_los(*svs, lats=lats, lons=lons, heights=heights) - - # Otherwise, throw an error - except: - raise ValueError('infer_los: I cannot parse the file {}'.format(los_file)) - - return LOS + return np.stack([e, n, u], axis=-1) def get_sv(los_file, ref_time, pad=3*3600): """ - Read an LOS file. + Read an LOS file and return orbital state vectors Parameters ---------- @@ -155,7 +153,7 @@ def get_sv(los_file, ref_time, pad=3*3600): return svs -def los_to_lv(incidence, heading): +def inc_hd_to_enu(incidence, heading): ''' Convert incidence and heading to line-of-sight vectors from the ground to the top of the troposphere. @@ -173,7 +171,7 @@ def los_to_lv(incidence, heading): Algorithm referenced from http://earthdef.caltech.edu/boards/4/topics/327 ''' if np.any(incidence < 0): - raise ValueError('los_to_lv: Incidence angle cannot be less than 0') + raise ValueError('inc_hd_to_enu: Incidence angle cannot be less than 0') east = utilFcns.sind(incidence) * utilFcns.cosd(heading + 90) north = utilFcns.sind(incidence) * utilFcns.sind(heading + 90) From 8ea053eb36419a3c18d1020ab092e6cac831bd00 Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Thu, 15 Jul 2021 13:31:33 -0500 Subject: [PATCH 14/27] clarify a couple points in losreader --- tools/RAiDER/losreader.py | 18 +++++++++--------- tools/RAiDER/utilFcns.py | 12 ------------ 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/tools/RAiDER/losreader.py b/tools/RAiDER/losreader.py index 0ccc6e716..14f986825 100644 --- a/tools/RAiDER/losreader.py +++ b/tools/RAiDER/losreader.py @@ -28,6 +28,11 @@ def getLookVectors(look_vecs, lats, lons, heights, time=None, pad=3*3600): or to Zenith. Can be accomplished using an ISCE-style 2-band LOS file or a file containing orbital statevectors. + *NOTE*: + These line-of-sight vectors will NOT match ordinary LOS vectors for InSAR + because they are in an ECEF reference frame instead of a local ENU. This is done + because the construction of rays is done in ECEF rather than the local ENU. + Parameters ---------- look_vecs: LookVector object or tuple - Either a Zenith object or a tuple, @@ -109,11 +114,11 @@ def getZenithLookVecs(lats, lons, heights): ------- zenLookVecs: ndarray - (in_shape) x 3 unit look vectors in an ECEF reference frame ''' - e = np.cos(np.radians(lats)) * np.cos(np.radians(lons)) - n = np.cos(np.radians(lats)) * np.sin(np.radians(lons)) - u = np.sin(np.radians(lats)) + x = np.cos(np.radians(lats)) * np.cos(np.radians(lons)) + y = np.cos(np.radians(lats)) * np.sin(np.radians(lons)) + z = np.sin(np.radians(lats)) - return np.stack([e, n, u], axis=-1) + return np.stack([x, y, z], axis=-1) def get_sv(los_file, ref_time, pad=3*3600): @@ -195,11 +200,6 @@ def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights): ------- LOS - * x 3 matrix of LOS unit vectors in ECEF (*not* ENU) - *NOTE*: - These line-of-sight vectors will NOT match ordinary LOS vectors for InSAR - because they are in an ECEF reference frame instead of a local ENU. This is done - because the construction of rays is done in ECEF rather than the local ENU. - Example: >>> import datetime >>> from RAiDER.utilFcns import gdal_open diff --git a/tools/RAiDER/utilFcns.py b/tools/RAiDER/utilFcns.py index cd0e06299..1f08f7954 100755 --- a/tools/RAiDER/utilFcns.py +++ b/tools/RAiDER/utilFcns.py @@ -192,18 +192,6 @@ def writeArrayToFile(lats, lons, array, filename, noDataValue=-9999): f.write('{},{},{}\n'.format(l, L, a)) -def round_time(dt=None, roundTo=60): - """Round a datetime object to any time lapse in seconds - dt : datetime.datetime object, default now. - roundTo : Closest number of seconds to round to, default 1 minute. - Author: Thierry Husson 2012 - Use it as you want but don't blame me. - """ - if dt == None : dt = datetime.now() - seconds = (dt.replace(tzinfo=None) - dt.min).seconds - rounding = (seconds+roundTo/2) // roundTo * roundTo - return dt + timedelta(0,rounding-seconds,-dt.microsecond) - - def round_date(date, precision): # First try rounding up # Timedelta since the beginning of time From eb6cd95c25a3d471f9e51642b66b734187366ad3 Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Thu, 15 Jul 2021 15:12:49 -0500 Subject: [PATCH 15/27] start refactoring LOS calc --- tools/RAiDER/delayFcns.py | 74 +++++++++++++-------------------------- 1 file changed, 25 insertions(+), 49 deletions(-) diff --git a/tools/RAiDER/delayFcns.py b/tools/RAiDER/delayFcns.py index 3b4066b6a..f4d35ad26 100755 --- a/tools/RAiDER/delayFcns.py +++ b/tools/RAiDER/delayFcns.py @@ -16,9 +16,10 @@ from pyproj import CRS, Transformer from scipy.interpolate import RegularGridInterpolator -from RAiDER.constants import _STEP +from RAiDER.constants import _STEP, _ZREF, _RE from RAiDER.interpolator import RegularGridInterpolator as Interpolator from RAiDER.makePoints import makePoints1D +from RAiDER.losreader import getZenithLookVecs def calculate_rays(pnts_file, stepSize=_STEP): @@ -26,50 +27,6 @@ def calculate_rays(pnts_file, stepSize=_STEP): From a set of lats/lons/hgts, compute ray paths from the ground to the top of the atmosphere, using either a set of look vectors or the zenith ''' - # get the lengths of each ray for doing the interpolation - getUnitLVs(pnts_file) - - # This projects the ground pixels into earth-centered, earth-fixed coordinate - # system and sorts by position - lla2ecef(pnts_file) - - -def getUnitLVs(pnts_file): - ''' - Get a set of look vectors normalized by their lengths - ''' - get_lengths(pnts_file) - with h5py.File(pnts_file, 'r+') as f: - slv = f['LOS'][()] / f['Rays_len'][()][..., np.newaxis] - f['Rays_SLV'][...] = slv - - -def get_lengths(pnts_file): - ''' - Returns the lengths of a vector or set of vectors, fast. - Inputs: - looks_vecs - an Nx3 numpy array containing look vectors with absolute - lengths; i.e., the absolute position of the top of the - atmosphere. - Outputs: - lengths - an Nx1 numpy array containing the absolute distance in - meters of the top of the atmosphere from the ground pnt. - ''' - with h5py.File(pnts_file, 'r+') as f: - lengths = np.linalg.norm(f['LOS'][()], axis=-1) - try: - lengths[~np.isfinite(lengths)] = 0 - except TypeError: - if ~np.isfinite(lengths): - lengths = 0 - f['Rays_len'][:] = lengths.astype(np.float64) - f['Rays_len'].attrs['MaxLen'] = np.nanmax(lengths) - - -def lla2ecef(pnts_file): - ''' - reproject a set of lat/lon/hgts to earth-centered, earth-fixed coordinate system - ''' t = Transformer.from_crs(4326, 4978, always_xy=True) # converts from WGS84 geodetic to WGS84 geocentric with h5py.File(pnts_file, 'r+') as f: @@ -77,11 +34,30 @@ def lla2ecef(pnts_file): lon = f['lon'][()] lat = f['lat'][()] hgt = f['hgt'][()] - lon[lon == ndv] = np.nan - lat[lat == ndv] = np.nan - hgt[hgt == ndv] = np.nan - sp = np.moveaxis(np.array(t.transform(lon, lat, hgt)), 0, -1) + los = f['LOS'][()] + + lon[lon == ndv] = np.nan + lat[lat == ndv] = np.nan + hgt[hgt == ndv] = np.nan + + sp = np.moveaxis(np.array(t.transform(lon, lat, hgt)), 0, -1) + + # To get the ray lengths, we use the parametric form of the equation of a line in 3D: + # L = r0 + v*t, where r0 is the target position in ECEF, and v is the LOS vector (also ECEF) + # Then, using r_tropo = zref - (R_E + h), set |r0 + v*t| = |r_tropo|. Now use + # vector algebra: |r0 + v*t| = r0'*r0 + 2*t*(v'*r0) + (t^2)*(v'*v), where "'" denotes transpose. + # This gives a quadratic system in t to be solved: + # t = (-2*(v'*r0) - sqrt(4*(v'*r0)^2 - 4*(r_target^2 - r_tropo^2)) ) / 2*(r_target^2 - r_tropo^2) + # where r_target = r0'*r0 and we have used v'*v = 1. Noting that r_tropo^2 - r_target^2 ~= 2*R_E*Zref, + # we get t ~= ( v'*r0 + sqrt((v'*r0)^2 + 2*R_E*Zref)) / 2*R_E*Zref + vr0 = los[...,0]*sp[...,0] + los[...,1]*sp[...,1] + los[...,2]*sp[...,2] + lengths = (vr0 + np.sqrt(np.square(vr0) + 2*_RE*_ZREF)) / (2*_RE*_ZREF) + + with h5py.File(pnts_file, 'r+') as f: f['Rays_SP'][...] = sp.astype(np.float64) # ensure double is maintained + f['Rays_SLV'][...] = los + f['Rays_len'][:] = lengths.astype(np.float64) + f['Rays_len'].attrs['MaxLen'] = np.nanmax(lengths) def get_delays( From a8f17e4ebb5d145ce9cdce05271df54b2042a67c Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Thu, 15 Jul 2021 15:17:34 -0500 Subject: [PATCH 16/27] move some files around --- test/scenario_3/S1_orbit_example.EOF | 136 +++++++++++++++++++++++++++ test/scenario_3/S1_sv_file.txt | 8 ++ test/test_losreader.py | 17 ++-- 3 files changed, 154 insertions(+), 7 deletions(-) create mode 100644 test/scenario_3/S1_orbit_example.EOF create mode 100644 test/scenario_3/S1_sv_file.txt diff --git a/test/scenario_3/S1_orbit_example.EOF b/test/scenario_3/S1_orbit_example.EOF new file mode 100644 index 000000000..41e960e17 --- /dev/null +++ b/test/scenario_3/S1_orbit_example.EOF @@ -0,0 +1,136 @@ + + + + + S1A_OPER_AUX_POEORB_OPOD_20181203T120749_V20181112T225942_20181114T005942 + Precise Orbit Ephemerides (POE) Orbit File + + Sentinel-1A + OPER + AUX_POEORB + + UTC=2018-11-12T22:59:42 + UTC=2018-11-14T00:59:42 + + 0001 + + OPOD + OPOD + 1.5.3 + UTC=2018-12-03T12:07:49 + + + + EARTH_FIXED + UTC + + + + + + TAI=2018-11-12T23:00:39.000000 + UTC=2018-11-12T23:00:02.000000 + UT1=2018-11-12T23:00:02.007459 + +24561 + -2064965.285362 + 6434865.494987 + 2090670.967443 + 860.239634 + 2590.964968 + -7090.378144 + NOMINAL + + + TAI=2018-11-12T23:00:49.000000 + UTC=2018-11-12T23:00:12.000000 + UT1=2018-11-12T23:00:12.007459 + +24561 + -2056228.553736 + 6460407.492520 + 2019650.417312 + 887.072466 + 2517.380329 + -7113.598127 + NOMINAL + + + TAI=2018-11-12T23:00:59.000000 + UTC=2018-11-12T23:00:22.000000 + UT1=2018-11-12T23:00:22.007459 + +24561 + -2047224.526705 + 6485212.031660 + 1948401.684024 + 913.698134 + 2443.474728 + -7136.014344 + NOMINAL + + + TAI=2018-11-12T23:01:09.000000 + UTC=2018-11-12T23:00:32.000000 + UT1=2018-11-12T23:00:32.007459 + +24561 + -2037955.293282 + 6509275.946120 + 1876932.818066 + 940.113169 + 2369.256838 + -7157.624244 + NOMINAL + + + TAI=2018-11-12T23:01:19.000000 + UTC=2018-11-12T23:00:42.000000 + UT1=2018-11-12T23:00:42.007459 + +24561 + -2028422.977002 + 6532596.156540 + 1805251.894958 + 966.314136 + 2294.735374 + -7178.425371 + NOMINAL + + + TAI=2018-11-12T23:01:29.000000 + UTC=2018-11-12T23:00:52.000000 + UT1=2018-11-12T23:00:52.007459 + +24561 + -2018629.735564 + 6555169.670917 + 1733367.014327 + 992.297636 + 2219.919093 + -7198.415359 + NOMINAL + + + TAI=2018-11-12T23:01:39.000000 + UTC=2018-11-12T23:01:02.000000 + UT1=2018-11-12T23:01:02.007459 + +24561 + -2008577.760461 + 6576993.585012 + 1661286.298987 + 1018.060311 + 2144.816789 + -7217.591940 + NOMINAL + + + TAI=2018-11-12T23:01:49.000000 + UTC=2018-11-12T23:01:12.000000 + UT1=2018-11-12T23:01:12.007458 + +24561 + -1998269.276601 + 6598065.082739 + 1589017.893976 + 1043.598837 + 2069.437298 + -7235.952940 + NOMINAL + + + + diff --git a/test/scenario_3/S1_sv_file.txt b/test/scenario_3/S1_sv_file.txt new file mode 100644 index 000000000..e99f09bfd --- /dev/null +++ b/test/scenario_3/S1_sv_file.txt @@ -0,0 +1,8 @@ +-40.00 -2064965.285362 6434865.494987 2090670.967443 860.239634 2590.964968 -7090.378144 +-30.00 -2056228.553736 6460407.492520 2019650.417312 887.072466 2517.380329 -7113.598127 +-20.00 -2047224.526705 6485212.031660 1948401.684024 913.698134 2443.474728 -7136.014344 +-10.00 -2037955.293282 6509275.946120 1876932.818066 940.113169 2369.256838 -7157.624244 +0.00 -2028422.977002 6532596.156540 1805251.894958 966.314136 2294.735374 -7178.425371 +10.00 -2018629.735564 6555169.670917 1733367.014327 992.297636 2219.919093 -7198.415359 +20.00 -2008577.760461 6576993.585012 1661286.298987 1018.060311 2144.816789 -7217.591940 +30.00 -1998269.276601 6598065.082739 1589017.893976 1043.598837 2069.437298 -7235.952940 diff --git a/test/test_losreader.py b/test/test_losreader.py index 9f0bf3889..129bc8fa5 100644 --- a/test/test_losreader.py +++ b/test/test_losreader.py @@ -1,7 +1,7 @@ import datetime import os import pytest -from test import DATA_DIR +from test import TEST_DIR import numpy as np @@ -14,6 +14,9 @@ getZenithLookVecs, ) +SCENARIO_DIR = os.path.join(TEST_DIR, "scenario_3") + + @pytest.fixture def svs(): ref_time = datetime.datetime(2018, 11, 12, 23, 0, 42) @@ -93,37 +96,37 @@ def svs(): def test_read_ESA_Orbit_file(svs): true_svs, ref_time = svs - filename = os.path.join(DATA_DIR, 'S1_orbit_example.EOF') + filename = os.path.join(SCENARIO_DIR, 'S1_orbit_example.EOF') svs = read_ESA_Orbit_file(filename, ref_time) assert [np.allclose(s, ts) for s, ts in zip(svs, true_svs)] def test_read_txt_file(svs): true_svs, ref_time = svs - filename = os.path.join(DATA_DIR, 'S1_sv_file.txt') + filename = os.path.join(SCENARIO_DIR, 'S1_sv_file.txt') svs = read_txt_file(filename) assert [np.allclose(s, ts) for s, ts in zip(svs, true_svs)] def test_get_sv_1(svs): true_svs, ref_time = svs - filename = os.path.join(DATA_DIR, 'S1_orbit_example.EOF') + filename = os.path.join(SCENARIO_DIR, 'S1_orbit_example.EOF') svs = get_sv(filename, ref_time) assert [np.allclose(s, ts) for s, ts in zip(svs, true_svs)] def test_get_sv_2(svs): true_svs, ref_time = svs - filename = os.path.join(DATA_DIR, 'S1_sv_file.txt') + filename = os.path.join(SCENARIO_DIR, 'S1_sv_file.txt') svs = get_sv(filename, ref_time) assert [np.allclose(s, ts) for s, ts in zip(svs, true_svs)] def test_get_sv_3(svs): true_svs, ref_time = svs - filename = os.path.join(DATA_DIR, 'geom', 'warpedDEM.dem') + filename = os.path.join(SCENARIO_DIR, 'dummy.txt') with pytest.raises(ValueError): get_sv(filename, ref_time) def test_get_sv_4(svs): true_svs, ref_time = svs - filename = os.path.join(DATA_DIR, 'no_exist.txt') + filename = os.path.join(SCENARIO_DIR, 'no_exist.txt') with pytest.raises(FileNotFoundError): get_sv(filename, ref_time) From f251d022f71dbbb771d8da7eddc49e4d48ba97b4 Mon Sep 17 00:00:00 2001 From: bbuzz31 Date: Thu, 15 Jul 2021 13:27:54 -0700 Subject: [PATCH 17/27] BB_few_fixes change name of variable (los_file -> lookvector) fix masking with a reshape make shape of outputs consistent (LOS file, orbit file) --- tools/RAiDER/delay.py | 6 ++- tools/RAiDER/delayFcns.py | 10 ++--- tools/RAiDER/losreader.py | 93 ++++++++++++++++++++------------------- 3 files changed, 56 insertions(+), 53 deletions(-) diff --git a/tools/RAiDER/delay.py b/tools/RAiDER/delay.py index fe4f3d502..08f5c657a 100755 --- a/tools/RAiDER/delay.py +++ b/tools/RAiDER/delay.py @@ -34,8 +34,8 @@ def computeDelay( out=None, ): """ - Calculate troposphere delay using a weather model file and query - points file. + Calculate troposphere delay using a weather model file and query + points file. """ logger.debug('Beginning delay calculation') logger.debug('Max integration height is {:1.1f} m'.format(zref)) @@ -62,6 +62,7 @@ def computeDelay( step ) + wet, hydro = RAiDER.delayFcns.get_delays( step, pnts_file_name, @@ -171,6 +172,7 @@ def tropo_delay(args): # Convert the line-of-sight inputs to look vectors los = getLookVectors(los, lats, lons, hgts, time) + np.save('./HR_SV/LOS.npy', los) # write to an HDF5 file writePnts2HDF5(lats, lons, hgts, los, outName=pnts_file) diff --git a/tools/RAiDER/delayFcns.py b/tools/RAiDER/delayFcns.py index f4d35ad26..1fc958193 100755 --- a/tools/RAiDER/delayFcns.py +++ b/tools/RAiDER/delayFcns.py @@ -44,14 +44,14 @@ def calculate_rays(pnts_file, stepSize=_STEP): # To get the ray lengths, we use the parametric form of the equation of a line in 3D: # L = r0 + v*t, where r0 is the target position in ECEF, and v is the LOS vector (also ECEF) - # Then, using r_tropo = zref - (R_E + h), set |r0 + v*t| = |r_tropo|. Now use + # Then, using r_tropo = zref - (R_E + h), set |r0 + v*t| = |r_tropo|. Now use # vector algebra: |r0 + v*t| = r0'*r0 + 2*t*(v'*r0) + (t^2)*(v'*v), where "'" denotes transpose. - # This gives a quadratic system in t to be solved: + # This gives a quadratic system in t to be solved: # t = (-2*(v'*r0) - sqrt(4*(v'*r0)^2 - 4*(r_target^2 - r_tropo^2)) ) / 2*(r_target^2 - r_tropo^2) # where r_target = r0'*r0 and we have used v'*v = 1. Noting that r_tropo^2 - r_target^2 ~= 2*R_E*Zref, - # we get t ~= ( v'*r0 + sqrt((v'*r0)^2 + 2*R_E*Zref)) / 2*R_E*Zref - vr0 = los[...,0]*sp[...,0] + los[...,1]*sp[...,1] + los[...,2]*sp[...,2] - lengths = (vr0 + np.sqrt(np.square(vr0) + 2*_RE*_ZREF)) / (2*_RE*_ZREF) + # we get t ~= ( v'*r0 + sqrt((v'*r0)^2 + 2*R_E*Zref)) / 2*R_E*Zref + vr0 = los[...,0]*sp[...,0] + los[...,1]*sp[...,1] + los[...,2]*sp[...,2] + lengths = (vr0 + np.sqrt(np.square(vr0) + 2*_RE*_ZREF)) / (2*_RE*_ZREF) with h5py.File(pnts_file, 'r+') as f: f['Rays_SP'][...] = sp.astype(np.float64) # ensure double is maintained diff --git a/tools/RAiDER/losreader.py b/tools/RAiDER/losreader.py index 14f986825..f1d89f6db 100644 --- a/tools/RAiDER/losreader.py +++ b/tools/RAiDER/losreader.py @@ -24,32 +24,32 @@ def getLookVectors(look_vecs, lats, lons, heights, time=None, pad=3*3600): ''' - Get unit look vectors pointing from the ground (target) pixels to the sensor, - or to Zenith. Can be accomplished using an ISCE-style 2-band LOS file or a - file containing orbital statevectors. + Get unit look vectors pointing from the ground (target) pixels to the sensor, + or to Zenith. Can be accomplished using an ISCE-style 2-band LOS file or a + file containing orbital statevectors. *NOTE*: - These line-of-sight vectors will NOT match ordinary LOS vectors for InSAR - because they are in an ECEF reference frame instead of a local ENU. This is done + These line-of-sight vectors will NOT match ordinary LOS vectors for InSAR + because they are in an ECEF reference frame instead of a local ENU. This is done because the construction of rays is done in ECEF rather than the local ENU. Parameters ---------- - look_vecs: LookVector object or tuple - Either a Zenith object or a tuple, - with the second element containing - the name of either a line-of-sight + look_vecs: LookVector object or tuple - Either a Zenith object or a tuple, + with the second element containing + the name of either a line-of-sight file or orbital statevectors file lats/lons/heights: ndarray - WGS-84 coordinates of the target pixels - time: python datetime - user-requested query time. Must be + time: python datetime - user-requested query time. Must be compatible with the orbit file passed. Only required for a statevector file. - pad: int - integer number of seconds to pad around + pad: int - integer number of seconds to pad around the user-specified time; default 3 hours Only required for a statevector file. Returns ------- - look_vecs: ndarray - an x 3 array of unit look vectors, defined in an + look_vecs: ndarray - an x 3 array of unit look vectors, defined in an Earth-centered, earth-fixed reference frame (ECEF). Convention is vectors point from the target pixel to the sensor. @@ -75,29 +75,32 @@ def getLookVectors(look_vecs, lats, lons, heights, time=None, pad=3*3600): look_vecs = getZenithLookVecs(lat, lon, hgt) else: try: - LOS_enu = inc_hd_to_enu(*utilFcns.gdal_open(los_file)) + LOS_enu = inc_hd_to_enu(*utilFcns.gdal_open(look_vecs)) look_vecs = utilFcns.enu2ecef( - LOS_enu[...,0], - LOS_enu[...,1], - LOS_enu[...,2], - lats, - lons, + LOS_enu[...,0], + LOS_enu[...,1], + LOS_enu[...,2], + lats, + lons, heights ) # if that doesn't work, try parsing as a statevector (orbit) file except OSError: - svs = get_sv(los_file, time, pad) + svs = get_sv(look_vecs, time, pad) look_vecs = state_to_los(*svs, lats=lats, lons=lons, heights=heights) + ## match the shape from LOS file reader (inc_hd_to_enu) + look_vecs = look_vecs.reshape((3,) + in_shape) # Otherwise, throw an error except: raise ValueError( - 'getLookVectors: I cannot parse the file {}'.format(los_file) + 'getLookVectors: I cannot parse the file {}'.format(look_vecs) ) - mask = np.isnan(hgt) | np.isnan(lat) | np.isnan(lon) - look_vecs[mask, :] = np.nan + mask = (np.isnan(hgt) | np.isnan(lat) | np.isnan(lon)).reshape( + look_vecs.shape[1:]) + look_vecs[:, mask] = np.nan return look_vecs.reshape(in_shape + (3,)).astype(np.float64) @@ -127,17 +130,17 @@ def get_sv(los_file, ref_time, pad=3*3600): Parameters ---------- - los_file: str - user-passed file containing either look + los_file: str - user-passed file containing either look vectors or statevectors for the sensor ref_time: python datetime - User-requested datetime; if not encompassed by the orbit times will raise a ValueError - pad: int - number of seconds to keep around the + pad: int - number of seconds to keep around the requested time Returns ------- - svs: 7 x 1 list of Nt x 1 ndarrays - the times, x/y/z positions and - velocities of the sensor for the given + svs: 7 x 1 list of Nt x 1 ndarrays - the times, x/y/z positions and + velocities of the sensor for the given window around the reference time """ try: @@ -167,11 +170,11 @@ def inc_hd_to_enu(incidence, heading): ---------- incidence: ndarray - incidence angle in deg from vertical heading: ndarray - heading angle in deg clockwise from north - lats/lons/heights: ndarray - WGS84 ellipsoidal target (ground pixel) locations + lats/lons/heights: ndarray - WGS84 ellipsoidal target (ground pixel) locations Returns ------- - LOS: ndarray - (input_shape) x 3 array of unit look vectors in local ENU + LOS: ndarray - (input_shape) x 3 array of unit look vectors in local ENU Algorithm referenced from http://earthdef.caltech.edu/boards/4/topics/327 ''' @@ -181,7 +184,7 @@ def inc_hd_to_enu(incidence, heading): east = utilFcns.sind(incidence) * utilFcns.cosd(heading + 90) north = utilFcns.sind(incidence) * utilFcns.sind(heading + 90) up = utilFcns.cosd(incidence) - + return np.stack((east, north, up), axis=-1) @@ -200,7 +203,7 @@ def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights): ------- LOS - * x 3 matrix of LOS unit vectors in ECEF (*not* ENU) - Example: + Example: >>> import datetime >>> from RAiDER.utilFcns import gdal_open >>> import RAiDER.losreader as losr @@ -252,10 +255,10 @@ def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights): raise RuntimeError( ''' state_to_los: - It appears that your input datetime and/or orbit file does not - correspond to the lats/lons that you've passed. Please verify - that the input datetime is the closest possible to the - acquisition times of the interferogram, and the orbit file covers + It appears that your input datetime and/or orbit file does not + correspond to the lats/lons that you've passed. Please verify + that the input datetime is the closest possible to the + acquisition times of the interferogram, and the orbit file covers the same range of time. ''' ) @@ -265,20 +268,20 @@ def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights): def cut_times(times, pad=3600*3): - """ - Slice the orbit file around the reference aquisition time. This is done - by default using a three-hour window, which for Sentinel-1 empirically + """ + Slice the orbit file around the reference aquisition time. This is done + by default using a three-hour window, which for Sentinel-1 empirically works out to be roughly the largest window allowed by the orbit time. Parameters ---------- - times: Nt x 1 ndarray - Vector of orbit times as seconds since the + times: Nt x 1 ndarray - Vector of orbit times as seconds since the user-requested time pad: int - integer time in seconds to use as padding Returns ------- - idx: Nt x 1 logical ndarray - a mask of times within the padded request time. + idx: Nt x 1 logical ndarray - a mask of times within the padded request time. """ return np.abs(times) < pad @@ -313,18 +316,18 @@ def read_shelve(filename): def read_txt_file(filename): ''' Read a 7-column text file containing orbit statevectors. Time - should be denoted as integer time in seconds since the reference - epoch (user-requested time). + should be denoted as integer time in seconds since the reference + epoch (user-requested time). Parameters ---------- filename: str - user-supplied space-delimited text file with no header - containing orbital statevectors as 7 columns: + containing orbital statevectors as 7 columns: - time in seconds since the user-supplied epoch - x / y / z locations in ECEF cartesian coordinates - vx / vy / vz velocities in m/s in ECEF coordinates Returns - svs: list - a length-7 list of numpy vectors containing the above + svs: list - a length-7 list of numpy vectors containing the above variables ''' t = list() @@ -356,7 +359,7 @@ def read_txt_file(filename): def read_ESA_Orbit_file(filename, ref_time): ''' Read orbit data from an orbit file supplied by ESA - + Parameters ---------- filename: str - string of the orbit filename @@ -387,7 +390,7 @@ def read_ESA_Orbit_file(filename, ref_time): for i, st in enumerate(data_block[0]): t[i] = ( datetime.datetime.strptime( - st[1].text, + st[1].text, 'UTC=%Y-%m-%dT%H:%M:%S.%f' ) - ref_time ).total_seconds() @@ -400,5 +403,3 @@ def read_ESA_Orbit_file(filename, ref_time): vz[i] = float(st[9].text) return [t, x, y, z, vx, vy, vz] - - From 53b618b0420031229deb8a4304906fb2c9d21859 Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Fri, 16 Jul 2021 10:31:24 -0500 Subject: [PATCH 18/27] Ensure that input shape is preserved in losreader --- tools/RAiDER/losreader.py | 42 +++++++++++++++++++-------------------- tools/RAiDER/utilFcns.py | 2 +- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/tools/RAiDER/losreader.py b/tools/RAiDER/losreader.py index f1d89f6db..1bcc64cfb 100644 --- a/tools/RAiDER/losreader.py +++ b/tools/RAiDER/losreader.py @@ -67,12 +67,9 @@ def getLookVectors(look_vecs, lats, lons, heights, time=None, pad=3*3600): look_vecs = look_vecs[1] in_shape = lats.shape - lat = lats.flatten() - lon = lons.flatten() - hgt = heights.flatten() if look_vecs is Zenith: - look_vecs = getZenithLookVecs(lat, lon, hgt) + look_vecs = getZenithLookVecs(lats, lons, heights) else: try: LOS_enu = inc_hd_to_enu(*utilFcns.gdal_open(look_vecs)) @@ -89,8 +86,6 @@ def getLookVectors(look_vecs, lats, lons, heights, time=None, pad=3*3600): except OSError: svs = get_sv(look_vecs, time, pad) look_vecs = state_to_los(*svs, lats=lats, lons=lons, heights=heights) - ## match the shape from LOS file reader (inc_hd_to_enu) - look_vecs = look_vecs.reshape((3,) + in_shape) # Otherwise, throw an error except: @@ -98,11 +93,10 @@ def getLookVectors(look_vecs, lats, lons, heights, time=None, pad=3*3600): 'getLookVectors: I cannot parse the file {}'.format(look_vecs) ) - mask = (np.isnan(hgt) | np.isnan(lat) | np.isnan(lon)).reshape( - look_vecs.shape[1:]) - look_vecs[:, mask] = np.nan + mask = (np.isnan(heights) | np.isnan(lats) | np.isnan(lons)) + look_vecs[mask, :] = np.nan - return look_vecs.reshape(in_shape + (3,)).astype(np.float64) + return look_vecs.astype(np.float64) def getZenithLookVecs(lats, lons, heights): @@ -226,29 +220,33 @@ def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights): if lats.shape != lons.shape: raise RuntimeError('state_to_los: lats and lons must be the same size') - real_shape = lats.shape - lats = lats.flatten() - lons = lons.flatten() - heights = heights.flatten() - + in_shape = lats.shape geo2rdr_obj = Geo2rdr.PyGeo2rdr() geo2rdr_obj.set_orbit(t, x, y, z, vx, vy, vz) - los_ecef = np.zeros((3, len(lats))) - - for i, (lat, lon, height) in enumerate(zip(lats, lons, heights)): + los_x, los_y, los_z = [], [], [] + for i, (l, L, h) in enumerate(zip(lats.ravel(), lons.ravel(), heights.ravel())): # Geo2rdr is picky about how the heights look - height_array = np.array(((height,),)).astype(np.double) + height_array = np.array(((h,),)).astype(np.double) # Set the target pixel location - geo2rdr_obj.set_geo_coordinate(np.radians(lon), np.radians(lat), 1, 1, height_array) + geo2rdr_obj.set_geo_coordinate(np.radians(L), np.radians(l), 1, 1, height_array) # compute the look vector and target-sensor range in ECEF geo2rdr_obj.geo2rdr() # get back the line of sight unit vector # LOS is defined as pointing from the ground pixel to the sensor - los_ecef[:,i] = np.squeeze(geo2rdr_obj.get_los()) + los = np.squeeze(geo2rdr_obj.get_los()) + los_x.append(los[0]) + los_y.append(los[1]) + los_z.append(los[2]) + + los_ecef = np.stack([ + np.array(los_x).reshape(in_shape), + np.array(los_y).reshape(in_shape), + np.array(los_z).reshape(in_shape), + ], axis=-1) # Sanity check for purpose of tracking problems if geo2rdr_obj.get_slant_range() > _SLANT_RANGE_THRESH: @@ -264,7 +262,7 @@ def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights): ) del geo2rdr_obj - return los_ecef.T + return los_ecef def cut_times(times, pad=3600*3): diff --git a/tools/RAiDER/utilFcns.py b/tools/RAiDER/utilFcns.py index 1f08f7954..a41e781d4 100755 --- a/tools/RAiDER/utilFcns.py +++ b/tools/RAiDER/utilFcns.py @@ -57,7 +57,7 @@ def enu2ecef(east, north, up, lat0, lon0, h0): u = cosd(lon0) * t - sind(lon0) * east v = sind(lon0) * t + cosd(lon0) * east - my_ecef = np.stack((x0 + u, y0 + v, z0 + w)) + my_ecef = np.stack((x0 + u, y0 + v, z0 + w), axis=-1) return my_ecef From 59c848775beadaaa095c501fc2cf92a8d307a416 Mon Sep 17 00:00:00 2001 From: bbuzz318 Date: Tue, 20 Jul 2021 12:04:03 -0700 Subject: [PATCH 19/27] fix and write --- tools/RAiDER/delay.py | 4 +- tools/RAiDER/losreader.py | 7 +- tools/RAiDER/utilFcns.py | 50 +- .../geometry/cython/Geo2rdr/Geo2rdr.cpp | 1934 +++++------------ 4 files changed, 530 insertions(+), 1465 deletions(-) diff --git a/tools/RAiDER/delay.py b/tools/RAiDER/delay.py index 08f5c657a..357f30f5b 100755 --- a/tools/RAiDER/delay.py +++ b/tools/RAiDER/delay.py @@ -172,7 +172,9 @@ def tropo_delay(args): # Convert the line-of-sight inputs to look vectors los = getLookVectors(los, lats, lons, hgts, time) - np.save('./HR_SV/LOS.npy', los) + import RAiDER.utilFcns as utilFcns + los_enu = utilFcns.ecef2enu(los, lats, lons, hgts) + np.save('./HR_SV/LOS_ENU.npy', los_enu) # write to an HDF5 file writePnts2HDF5(lats, lons, hgts, los, outName=pnts_file) diff --git a/tools/RAiDER/losreader.py b/tools/RAiDER/losreader.py index 1bcc64cfb..8411948e2 100644 --- a/tools/RAiDER/losreader.py +++ b/tools/RAiDER/losreader.py @@ -243,12 +243,13 @@ def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights): los_z.append(los[2]) los_ecef = np.stack([ - np.array(los_x).reshape(in_shape), - np.array(los_y).reshape(in_shape), - np.array(los_z).reshape(in_shape), + np.array(los_x).reshape(in_shape), + np.array(los_y).reshape(in_shape), + np.array(los_z).reshape(in_shape), ], axis=-1) # Sanity check for purpose of tracking problems + # print ('Slant range', geo2rdr_obj.get_slant_range()) if geo2rdr_obj.get_slant_range() > _SLANT_RANGE_THRESH: raise RuntimeError( ''' diff --git a/tools/RAiDER/utilFcns.py b/tools/RAiDER/utilFcns.py index a41e781d4..449f5eb28 100755 --- a/tools/RAiDER/utilFcns.py +++ b/tools/RAiDER/utilFcns.py @@ -12,8 +12,8 @@ import progressbar from RAiDER.constants import ( - Zenith, - _g0 as g0, + Zenith, + _g0 as g0, _RE as Re, R_EARTH_MAX as Rmax, R_EARTH_MIN as Rmin, @@ -45,29 +45,33 @@ def lla2ecef(lat, lon, height): return pyproj.transform(lla, ecef, lon, lat, height, always_xy=True) + +def ecef2enu(xyz, lat, lon, height): + '''Convert ECEF xyz to ENU''' + x, y, z = xyz[...,0],xyz[...,1],xyz[...,2] + + t = cosd(lon) * x + sind(lon) * y + + e = -sind(lon) * x + cosd(lon) * y + n = -sind(lat) * t + cosd(lat) * z + u = cosd(lat) * t + sind(lat) * z + return np.stack((e, n, u), axis=-1) + def enu2ecef(east, north, up, lat0, lon0, h0): """Return ecef from enu coordinates.""" # I'm looking at # https://github.com/scivision/pymap3d/blob/master/pymap3d/__init__.py - x0, y0, z0 = lla2ecef(lat0, lon0, h0) - - t = cosd(lat0) * up - sind(lat0) * north - w = sind(lat0) * up + cosd(lat0) * north + # x0, y0, z0 = lla2ecef(lat0, lon0, h0) - u = cosd(lon0) * t - sind(lon0) * east - v = sind(lon0) * t + cosd(lon0) * east + x = cosd(lon0) * cosd(lat0) * up - cosd(lon0) *sind(lat0) * north - sind(lon0) * east + y = sind(lon0) * cosd(lat0) * up - sind(lon0) *sind(lat0) * north + cosd(lon0) * east + z = sind(lat0) * up + cosd(lat0) * north - my_ecef = np.stack((x0 + u, y0 + v, z0 + w), axis=-1) + # my_ecef = np.stack((x0 + u, y0 + v, z0 + w), axis=-1) + my_ecef = np.stack((x, y, z), axis=-1) return my_ecef -def ecef2enu(xyz_ecef, lat, lon, height): - '''Convert ECEF xyz to ENU''' - R = getRotMatrix(lat, lon) - inp = xyz_ecef# - lla2ecef(lat, lon, height) - out = np.dot(R, inp) - return out - def getRotMatrix(lat, lon): '''Rotation matrix for geographic transformations''' return np.array([ @@ -269,7 +273,7 @@ def _geo_to_ht(lats, hts): # Calculate Geometric Height, h h = (hts * Re) / (g_ll / g0 * Re - hts) - # from metpy + # from metpy # return (geopotential * Re) / (g0 * Re - geopotential) return h @@ -759,9 +763,9 @@ def write2NETCDF4core(nc_outfile, dimension_dict, dataset_dict, tran, mapping_na dimensions = () var = nc_outfile.createVariable( - mapping_name, - datatype, - dimensions, + mapping_name, + datatype, + dimensions, fill_value=None ) # variable made, now add attributes @@ -834,9 +838,9 @@ def convertLons(inLons): def read_NCMR_loginInfo(filepath=None): - + from pathlib import Path - + if filepath is None: filepath = str(Path.home())+'/.ncmrlogin' @@ -856,7 +860,7 @@ def show_progress(block_num, block_size, total_size): if pbar is None: pbar = progressbar.ProgressBar(maxval=total_size) pbar.start() - + downloaded = block_num * block_size if downloaded < total_size: pbar.update(downloaded) diff --git a/tools/bindings/geometry/cython/Geo2rdr/Geo2rdr.cpp b/tools/bindings/geometry/cython/Geo2rdr/Geo2rdr.cpp index fb1bce24e..1ce0d9f4a 100644 --- a/tools/bindings/geometry/cython/Geo2rdr/Geo2rdr.cpp +++ b/tools/bindings/geometry/cython/Geo2rdr/Geo2rdr.cpp @@ -1,12 +1,15 @@ -/* Generated by Cython 0.29.21 */ +/* Generated by Cython 0.29.22 */ /* BEGIN: Cython Metadata { "distutils": { "depends": [ "/Users/bb/Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h", + "/Users/bb/Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/core/include/numpy/arrayscalars.h", + "/Users/bb/Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h", + "/Users/bb/Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h", "/Users/bb/Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/core/include/numpy/ufuncobject.h", - "/Users/bb/Software_InSAR/RAiDER_git/tools/bindings/geometry/cpp/classes/Geometry/Geometry.h" + "/Users/bb/Software_InSAR/RAiDER-J/tools/bindings/geometry/cpp/classes/Geometry/Geometry.h" ], "extra_compile_args": [ "-std=c++11" @@ -16,16 +19,16 @@ ], "include_dirs": [ "/Users/bb/Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/core/include", - "/Users/bb/Software_InSAR/RAiDER_git/tools/bindings/geometry/cpp/classes/Geometry", - "/Users/bb/Software_InSAR/RAiDER_git/tools/bindings/geometry/cpp/classes/Utility", - "/Users/bb/Software_InSAR/RAiDER_git/tools/bindings/geometry/cpp/classes/Orbit" + "/Users/bb/Software_InSAR/RAiDER-J/tools/bindings/geometry/cpp/classes/Geometry", + "/Users/bb/Software_InSAR/RAiDER-J/tools/bindings/geometry/cpp/classes/Utility", + "/Users/bb/Software_InSAR/RAiDER-J/tools/bindings/geometry/cpp/classes/Orbit" ], "language": "c++", "name": "RAiDER.Geo2rdr", "sources": [ - "/Users/bb/Software_InSAR/RAiDER_git/tools/bindings/geometry/cython/Geo2rdr/Geo2rdr.pyx", - "/Users/bb/Software_InSAR/RAiDER_git/tools/bindings/geometry/cpp/classes/Orbit/Orbit.cc", - "/Users/bb/Software_InSAR/RAiDER_git/tools/bindings/geometry/cpp/classes/Geometry/Geometry.cc" + "/Users/bb/Software_InSAR/RAiDER-J/tools/bindings/geometry/cython/Geo2rdr/Geo2rdr.pyx", + "/Users/bb/Software_InSAR/RAiDER-J/tools/bindings/geometry/cpp/classes/Orbit/Orbit.cc", + "/Users/bb/Software_InSAR/RAiDER-J/tools/bindings/geometry/cpp/classes/Geometry/Geometry.cc" ] }, "module_name": "RAiDER.Geo2rdr" @@ -39,8 +42,8 @@ END: Cython Metadata */ #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_29_21" -#define CYTHON_HEX_VERSION 0x001D15F0 +#define CYTHON_ABI "0_29_22" +#define CYTHON_HEX_VERSION 0x001D16F0 #define CYTHON_FUTURE_DIVISION 1 #include #ifndef offsetof @@ -654,6 +657,9 @@ static CYTHON_INLINE float __PYX_NAN() { #include #include #include "numpy/arrayobject.h" +#include "numpy/ndarrayobject.h" +#include "numpy/ndarraytypes.h" +#include "numpy/arrayscalars.h" #include "numpy/ufuncobject.h" /* NumPy API declarations from "numpy/__init__.pxd" */ @@ -936,7 +942,7 @@ typedef struct { } __Pyx_BufFmt_Context; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":697 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":690 * # in Cython to enable them only on the right systems. * * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< @@ -945,7 +951,7 @@ typedef struct { */ typedef npy_int8 __pyx_t_5numpy_int8_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":698 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":691 * * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< @@ -954,7 +960,7 @@ typedef npy_int8 __pyx_t_5numpy_int8_t; */ typedef npy_int16 __pyx_t_5numpy_int16_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":699 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":692 * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< @@ -963,7 +969,7 @@ typedef npy_int16 __pyx_t_5numpy_int16_t; */ typedef npy_int32 __pyx_t_5numpy_int32_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":700 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":693 * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< @@ -972,7 +978,7 @@ typedef npy_int32 __pyx_t_5numpy_int32_t; */ typedef npy_int64 __pyx_t_5numpy_int64_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":704 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":697 * #ctypedef npy_int128 int128_t * * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< @@ -981,7 +987,7 @@ typedef npy_int64 __pyx_t_5numpy_int64_t; */ typedef npy_uint8 __pyx_t_5numpy_uint8_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":705 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":698 * * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< @@ -990,7 +996,7 @@ typedef npy_uint8 __pyx_t_5numpy_uint8_t; */ typedef npy_uint16 __pyx_t_5numpy_uint16_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":706 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":699 * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< @@ -999,7 +1005,7 @@ typedef npy_uint16 __pyx_t_5numpy_uint16_t; */ typedef npy_uint32 __pyx_t_5numpy_uint32_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":707 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":700 * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< @@ -1008,7 +1014,7 @@ typedef npy_uint32 __pyx_t_5numpy_uint32_t; */ typedef npy_uint64 __pyx_t_5numpy_uint64_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":711 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":704 * #ctypedef npy_uint128 uint128_t * * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< @@ -1017,7 +1023,7 @@ typedef npy_uint64 __pyx_t_5numpy_uint64_t; */ typedef npy_float32 __pyx_t_5numpy_float32_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":712 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":705 * * ctypedef npy_float32 float32_t * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< @@ -1026,7 +1032,7 @@ typedef npy_float32 __pyx_t_5numpy_float32_t; */ typedef npy_float64 __pyx_t_5numpy_float64_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":721 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":714 * # The int types are mapped a bit surprising -- * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t # <<<<<<<<<<<<<< @@ -1035,7 +1041,7 @@ typedef npy_float64 __pyx_t_5numpy_float64_t; */ typedef npy_long __pyx_t_5numpy_int_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":722 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":715 * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< @@ -1044,7 +1050,7 @@ typedef npy_long __pyx_t_5numpy_int_t; */ typedef npy_longlong __pyx_t_5numpy_long_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":723 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":716 * ctypedef npy_long int_t * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< @@ -1053,7 +1059,7 @@ typedef npy_longlong __pyx_t_5numpy_long_t; */ typedef npy_longlong __pyx_t_5numpy_longlong_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":725 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":718 * ctypedef npy_longlong longlong_t * * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< @@ -1062,7 +1068,7 @@ typedef npy_longlong __pyx_t_5numpy_longlong_t; */ typedef npy_ulong __pyx_t_5numpy_uint_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":726 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":719 * * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< @@ -1071,7 +1077,7 @@ typedef npy_ulong __pyx_t_5numpy_uint_t; */ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":727 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":720 * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< @@ -1080,7 +1086,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; */ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":729 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":722 * ctypedef npy_ulonglong ulonglong_t * * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< @@ -1089,7 +1095,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; */ typedef npy_intp __pyx_t_5numpy_intp_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":730 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":723 * * ctypedef npy_intp intp_t * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< @@ -1098,7 +1104,7 @@ typedef npy_intp __pyx_t_5numpy_intp_t; */ typedef npy_uintp __pyx_t_5numpy_uintp_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":732 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":725 * ctypedef npy_uintp uintp_t * * ctypedef npy_double float_t # <<<<<<<<<<<<<< @@ -1107,7 +1113,7 @@ typedef npy_uintp __pyx_t_5numpy_uintp_t; */ typedef npy_double __pyx_t_5numpy_float_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":733 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":726 * * ctypedef npy_double float_t * ctypedef npy_double double_t # <<<<<<<<<<<<<< @@ -1116,7 +1122,7 @@ typedef npy_double __pyx_t_5numpy_float_t; */ typedef npy_double __pyx_t_5numpy_double_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":734 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":727 * ctypedef npy_double float_t * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< @@ -1152,7 +1158,7 @@ static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(do /*--- Type declarations ---*/ struct __pyx_obj_6RAiDER_7Geo2rdr_PyGeo2rdr; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":736 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":729 * ctypedef npy_longdouble longdouble_t * * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< @@ -1161,7 +1167,7 @@ struct __pyx_obj_6RAiDER_7Geo2rdr_PyGeo2rdr; */ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":737 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":730 * * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< @@ -1170,7 +1176,7 @@ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; */ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":738 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":731 * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< @@ -1179,7 +1185,7 @@ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; */ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":740 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":733 * ctypedef npy_clongdouble clongdouble_t * * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< @@ -1371,64 +1377,6 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg /* RaiseException.proto */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); -/* DictGetItem.proto */ -#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY -static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key); -#define __Pyx_PyObject_Dict_GetItem(obj, name)\ - (likely(PyDict_CheckExact(obj)) ?\ - __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name)) -#else -#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) -#define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name) -#endif - -/* RaiseTooManyValuesToUnpack.proto */ -static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); - -/* RaiseNeedMoreValuesToUnpack.proto */ -static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); - -/* RaiseNoneIterError.proto */ -static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); - -/* PyCFunctionFastCall.proto */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); -#else -#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) -#endif - -/* PyFunctionFastCall.proto */ -#if CYTHON_FAST_PYCALL -#define __Pyx_PyFunction_FastCall(func, args, nargs)\ - __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); -#else -#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) -#endif -#define __Pyx_BUILD_ASSERT_EXPR(cond)\ - (sizeof(char [1 - 2*!(cond)]) - 1) -#ifndef Py_MEMBER_SIZE -#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) -#endif - static size_t __pyx_pyframe_localsplus_offset = 0; - #include "frameobject.h" - #define __Pxy_PyFrame_Initialize_Offsets()\ - ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\ - (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus))) - #define __Pyx_PyFrame_GetLocalsplus(frame)\ - (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset)) -#endif - -/* PyObjectCallMethO.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); -#endif - -/* PyObjectCallOneArg.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); - /* GetTopmostException.proto */ #if CYTHON_USE_EXC_INFO_STACK static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); @@ -1710,14 +1658,10 @@ static void __Pyx_CppExn2PyErr() { #endif #endif -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value); - -/* CIntFromPy.proto */ -static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); +/* GCCDiagnostics.proto */ +#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +#define __Pyx_HAS_GCC_DIAGNOSTIC +#endif /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); @@ -1725,6 +1669,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); +/* CIntFromPy.proto */ +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); + /* FastTypeChecks.proto */ #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) @@ -1773,8 +1720,17 @@ static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; +static PyTypeObject *__pyx_ptype_5numpy_generic = 0; +static PyTypeObject *__pyx_ptype_5numpy_number = 0; +static PyTypeObject *__pyx_ptype_5numpy_integer = 0; +static PyTypeObject *__pyx_ptype_5numpy_signedinteger = 0; +static PyTypeObject *__pyx_ptype_5numpy_unsignedinteger = 0; +static PyTypeObject *__pyx_ptype_5numpy_inexact = 0; +static PyTypeObject *__pyx_ptype_5numpy_floating = 0; +static PyTypeObject *__pyx_ptype_5numpy_complexfloating = 0; +static PyTypeObject *__pyx_ptype_5numpy_flexible = 0; +static PyTypeObject *__pyx_ptype_5numpy_character = 0; static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; -static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void); /*proto*/ /* Module declarations from 'Geo2rdr' */ @@ -1794,8 +1750,6 @@ int __pyx_module_is_main_RAiDER__Geo2rdr = 0; /* Implementation of 'RAiDER.Geo2rdr' */ static PyObject *__pyx_builtin_TypeError; -static PyObject *__pyx_builtin_RuntimeError; -static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_ImportError; static const char __pyx_k_x[] = "x"; static const char __pyx_k_y[] = "y"; @@ -1821,28 +1775,17 @@ static const char __pyx_k_TypeError[] = "TypeError"; static const char __pyx_k_lat_first[] = "lat_first"; static const char __pyx_k_lon_first[] = "lon_first"; static const char __pyx_k_reduce_ex[] = "__reduce_ex__"; -static const char __pyx_k_ValueError[] = "ValueError"; static const char __pyx_k_ImportError[] = "ImportError"; -static const char __pyx_k_RuntimeError[] = "RuntimeError"; static const char __pyx_k_reduce_cython[] = "__reduce_cython__"; static const char __pyx_k_setstate_cython[] = "__setstate_cython__"; static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; static const char __pyx_k_Copyright_c_2018_Authors_s_Here[] = "\n\nCopyright (c) 2018-\nAuthors(s): Heresh Fattahi\n\n"; static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import"; -static const char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)"; -static const char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd"; -static const char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported"; static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__"; static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import"; -static const char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short."; -static PyObject *__pyx_kp_u_Format_string_allocated_too_shor; -static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2; static PyObject *__pyx_n_s_ImportError; -static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor; static PyObject *__pyx_n_s_PyGeo2rdr; -static PyObject *__pyx_n_s_RuntimeError; static PyObject *__pyx_n_s_TypeError; -static PyObject *__pyx_n_s_ValueError; static PyObject *__pyx_n_s_cline_in_traceback; static PyObject *__pyx_n_s_getstate; static PyObject *__pyx_n_s_heights; @@ -1865,7 +1808,6 @@ static PyObject *__pyx_n_s_setstate; static PyObject *__pyx_n_s_setstate_cython; static PyObject *__pyx_n_s_test; static PyObject *__pyx_n_s_times; -static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd; static PyObject *__pyx_n_s_vx; static PyObject *__pyx_n_s_vy; static PyObject *__pyx_n_s_vz; @@ -1886,9 +1828,6 @@ static PyObject *__pyx_tuple_; static PyObject *__pyx_tuple__2; static PyObject *__pyx_tuple__3; static PyObject *__pyx_tuple__4; -static PyObject *__pyx_tuple__5; -static PyObject *__pyx_tuple__6; -static PyObject *__pyx_tuple__7; /* Late includes */ /* "tools/bindings/geometry/cython/Geo2rdr/Geo2rdr.pyx":24 @@ -3062,7 +3001,7 @@ static PyObject *__pyx_pf_6RAiDER_7Geo2rdr_9PyGeo2rdr_16__setstate_cython__(CYTH return __pyx_r; } -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":742 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":735 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -3079,7 +3018,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":743 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":736 * * cdef inline object PyArray_MultiIterNew1(a): * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< @@ -3087,13 +3026,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ * cdef inline object PyArray_MultiIterNew2(a, b): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 743, __pyx_L1_error) + __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 736, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":742 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":735 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -3112,7 +3051,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ return __pyx_r; } -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":745 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":738 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -3129,7 +3068,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":746 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":739 * * cdef inline object PyArray_MultiIterNew2(a, b): * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< @@ -3137,13 +3076,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ * cdef inline object PyArray_MultiIterNew3(a, b, c): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 746, __pyx_L1_error) + __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 739, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":745 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":738 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -3162,7 +3101,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ return __pyx_r; } -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":748 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":741 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -3179,7 +3118,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":749 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":742 * * cdef inline object PyArray_MultiIterNew3(a, b, c): * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< @@ -3187,13 +3126,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ * cdef inline object PyArray_MultiIterNew4(a, b, c, d): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 749, __pyx_L1_error) + __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 742, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":748 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":741 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -3212,7 +3151,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ return __pyx_r; } -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":751 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":744 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -3229,7 +3168,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":752 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":745 * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< @@ -3237,13 +3176,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 752, __pyx_L1_error) + __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 745, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":751 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":744 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -3262,7 +3201,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ return __pyx_r; } -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":754 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":747 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -3279,7 +3218,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":755 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":748 * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< @@ -3287,13 +3226,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ * cdef inline tuple PyDataType_SHAPE(dtype d): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 755, __pyx_L1_error) + __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 748, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":754 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":747 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -3312,7 +3251,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ return __pyx_r; } -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":757 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":750 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< @@ -3326,7 +3265,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ int __pyx_t_1; __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0); - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":758 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":751 * * cdef inline tuple PyDataType_SHAPE(dtype d): * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< @@ -3336,7 +3275,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0); if (__pyx_t_1) { - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":759 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":752 * cdef inline tuple PyDataType_SHAPE(dtype d): * if PyDataType_HASSUBARRAY(d): * return d.subarray.shape # <<<<<<<<<<<<<< @@ -3348,7 +3287,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape); goto __pyx_L0; - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":758 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":751 * * cdef inline tuple PyDataType_SHAPE(dtype d): * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< @@ -3357,12 +3296,12 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ */ } - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":761 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":754 * return d.subarray.shape * else: * return () # <<<<<<<<<<<<<< * - * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: + * */ /*else*/ { __Pyx_XDECREF(__pyx_r); @@ -3371,7 +3310,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ goto __pyx_L0; } - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":757 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":750 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< @@ -3386,756 +3325,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ return __pyx_r; } -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":763 - * return () - * - * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< - * # Recursive utility function used in __getbuffer__ to get format - * # string. The new location in the format string is returned. - */ - -static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { - PyArray_Descr *__pyx_v_child = 0; - int __pyx_v_endian_detector; - int __pyx_v_little_endian; - PyObject *__pyx_v_fields = 0; - PyObject *__pyx_v_childname = NULL; - PyObject *__pyx_v_new_offset = NULL; - PyObject *__pyx_v_t = NULL; - char *__pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - Py_ssize_t __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; - int __pyx_t_6; - int __pyx_t_7; - long __pyx_t_8; - char *__pyx_t_9; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("_util_dtypestring", 0); - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":768 - * - * cdef dtype child - * cdef int endian_detector = 1 # <<<<<<<<<<<<<< - * cdef bint little_endian = ((&endian_detector)[0] != 0) - * cdef tuple fields - */ - __pyx_v_endian_detector = 1; - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":769 - * cdef dtype child - * cdef int endian_detector = 1 - * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< - * cdef tuple fields - * - */ - __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":772 - * cdef tuple fields - * - * for childname in descr.names: # <<<<<<<<<<<<<< - * fields = descr.fields[childname] - * child, new_offset = fields - */ - if (unlikely(__pyx_v_descr->names == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - __PYX_ERR(2, 772, __pyx_L1_error) - } - __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; - for (;;) { - if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(2, 772, __pyx_L1_error) - #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 772, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - #endif - __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); - __pyx_t_3 = 0; - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":773 - * - * for childname in descr.names: - * fields = descr.fields[childname] # <<<<<<<<<<<<<< - * child, new_offset = fields - * - */ - if (unlikely(__pyx_v_descr->fields == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(2, 773, __pyx_L1_error) - } - __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 773, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(2, 773, __pyx_L1_error) - __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); - __pyx_t_3 = 0; - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":774 - * for childname in descr.names: - * fields = descr.fields[childname] - * child, new_offset = fields # <<<<<<<<<<<<<< - * - * if (end - f) - (new_offset - offset[0]) < 15: - */ - if (likely(__pyx_v_fields != Py_None)) { - PyObject* sequence = __pyx_v_fields; - Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); - if (unlikely(size != 2)) { - if (size > 2) __Pyx_RaiseTooManyValuesError(2); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(2, 774, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - #else - __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 774, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 774, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - } else { - __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(2, 774, __pyx_L1_error) - } - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) __PYX_ERR(2, 774, __pyx_L1_error) - __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); - __pyx_t_3 = 0; - __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); - __pyx_t_4 = 0; - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":776 - * child, new_offset = fields - * - * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") - * - */ - __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 776, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 776, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 776, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); - if (unlikely(__pyx_t_6)) { - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":777 - * - * if (end - f) - (new_offset - offset[0]) < 15: - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< - * - * if ((child.byteorder == c'>' and little_endian) or - */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 777, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(2, 777, __pyx_L1_error) - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":776 - * child, new_offset = fields - * - * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") - * - */ - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":779 - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") - * - * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< - * (child.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") - */ - __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); - if (!__pyx_t_7) { - goto __pyx_L8_next_or; - } else { - } - __pyx_t_7 = (__pyx_v_little_endian != 0); - if (!__pyx_t_7) { - } else { - __pyx_t_6 = __pyx_t_7; - goto __pyx_L7_bool_binop_done; - } - __pyx_L8_next_or:; - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":780 - * - * if ((child.byteorder == c'>' and little_endian) or - * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< - * raise ValueError(u"Non-native byte order not supported") - * # One could encode it in the format string and have Cython - */ - __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); - if (__pyx_t_7) { - } else { - __pyx_t_6 = __pyx_t_7; - goto __pyx_L7_bool_binop_done; - } - __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0); - __pyx_t_6 = __pyx_t_7; - __pyx_L7_bool_binop_done:; - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":779 - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") - * - * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< - * (child.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") - */ - if (unlikely(__pyx_t_6)) { - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":781 - * if ((child.byteorder == c'>' and little_endian) or - * (child.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< - * # One could encode it in the format string and have Cython - * # complain instead, BUT: < and > in format strings also imply - */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 781, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(2, 781, __pyx_L1_error) - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":779 - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") - * - * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< - * (child.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") - */ - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":791 - * - * # Output padding bytes - * while offset[0] < new_offset: # <<<<<<<<<<<<<< - * f[0] = 120 # "x"; pad byte - * f += 1 - */ - while (1) { - __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 791, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 791, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 791, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (!__pyx_t_6) break; - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":792 - * # Output padding bytes - * while offset[0] < new_offset: - * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< - * f += 1 - * offset[0] += 1 - */ - (__pyx_v_f[0]) = 0x78; - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":793 - * while offset[0] < new_offset: - * f[0] = 120 # "x"; pad byte - * f += 1 # <<<<<<<<<<<<<< - * offset[0] += 1 - * - */ - __pyx_v_f = (__pyx_v_f + 1); - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":794 - * f[0] = 120 # "x"; pad byte - * f += 1 - * offset[0] += 1 # <<<<<<<<<<<<<< - * - * offset[0] += child.itemsize - */ - __pyx_t_8 = 0; - (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":796 - * offset[0] += 1 - * - * offset[0] += child.itemsize # <<<<<<<<<<<<<< - * - * if not PyDataType_HASFIELDS(child): - */ - __pyx_t_8 = 0; - (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":798 - * offset[0] += child.itemsize - * - * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< - * t = child.type_num - * if end - f < 5: - */ - __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); - if (__pyx_t_6) { - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":799 - * - * if not PyDataType_HASFIELDS(child): - * t = child.type_num # <<<<<<<<<<<<<< - * if end - f < 5: - * raise RuntimeError(u"Format string allocated too short.") - */ - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 799, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); - __pyx_t_4 = 0; - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":800 - * if not PyDataType_HASFIELDS(child): - * t = child.type_num - * if end - f < 5: # <<<<<<<<<<<<<< - * raise RuntimeError(u"Format string allocated too short.") - * - */ - __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); - if (unlikely(__pyx_t_6)) { - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":801 - * t = child.type_num - * if end - f < 5: - * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< - * - * # Until ticket #99 is fixed, use integers to avoid warnings - */ - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 801, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_Raise(__pyx_t_4, 0, 0, 0); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(2, 801, __pyx_L1_error) - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":800 - * if not PyDataType_HASFIELDS(child): - * t = child.type_num - * if end - f < 5: # <<<<<<<<<<<<<< - * raise RuntimeError(u"Format string allocated too short.") - * - */ - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":804 - * - * # Until ticket #99 is fixed, use integers to avoid warnings - * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< - * elif t == NPY_UBYTE: f[0] = 66 #"B" - * elif t == NPY_SHORT: f[0] = 104 #"h" - */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 804, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 804, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 804, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 98; - goto __pyx_L15; - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":805 - * # Until ticket #99 is fixed, use integers to avoid warnings - * if t == NPY_BYTE: f[0] = 98 #"b" - * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< - * elif t == NPY_SHORT: f[0] = 104 #"h" - * elif t == NPY_USHORT: f[0] = 72 #"H" - */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 805, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 805, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 66; - goto __pyx_L15; - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":806 - * if t == NPY_BYTE: f[0] = 98 #"b" - * elif t == NPY_UBYTE: f[0] = 66 #"B" - * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< - * elif t == NPY_USHORT: f[0] = 72 #"H" - * elif t == NPY_INT: f[0] = 105 #"i" - */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 806, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 806, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x68; - goto __pyx_L15; - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":807 - * elif t == NPY_UBYTE: f[0] = 66 #"B" - * elif t == NPY_SHORT: f[0] = 104 #"h" - * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< - * elif t == NPY_INT: f[0] = 105 #"i" - * elif t == NPY_UINT: f[0] = 73 #"I" - */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 807, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 807, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 807, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 72; - goto __pyx_L15; - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":808 - * elif t == NPY_SHORT: f[0] = 104 #"h" - * elif t == NPY_USHORT: f[0] = 72 #"H" - * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< - * elif t == NPY_UINT: f[0] = 73 #"I" - * elif t == NPY_LONG: f[0] = 108 #"l" - */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 808, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 808, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 808, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x69; - goto __pyx_L15; - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":809 - * elif t == NPY_USHORT: f[0] = 72 #"H" - * elif t == NPY_INT: f[0] = 105 #"i" - * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< - * elif t == NPY_LONG: f[0] = 108 #"l" - * elif t == NPY_ULONG: f[0] = 76 #"L" - */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 809, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 809, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 809, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 73; - goto __pyx_L15; - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":810 - * elif t == NPY_INT: f[0] = 105 #"i" - * elif t == NPY_UINT: f[0] = 73 #"I" - * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< - * elif t == NPY_ULONG: f[0] = 76 #"L" - * elif t == NPY_LONGLONG: f[0] = 113 #"q" - */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 810, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 810, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 810, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x6C; - goto __pyx_L15; - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":811 - * elif t == NPY_UINT: f[0] = 73 #"I" - * elif t == NPY_LONG: f[0] = 108 #"l" - * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< - * elif t == NPY_LONGLONG: f[0] = 113 #"q" - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" - */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 811, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 811, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 811, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 76; - goto __pyx_L15; - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":812 - * elif t == NPY_LONG: f[0] = 108 #"l" - * elif t == NPY_ULONG: f[0] = 76 #"L" - * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" - * elif t == NPY_FLOAT: f[0] = 102 #"f" - */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 812, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 812, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 812, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x71; - goto __pyx_L15; - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":813 - * elif t == NPY_ULONG: f[0] = 76 #"L" - * elif t == NPY_LONGLONG: f[0] = 113 #"q" - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< - * elif t == NPY_FLOAT: f[0] = 102 #"f" - * elif t == NPY_DOUBLE: f[0] = 100 #"d" - */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 813, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 813, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 813, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 81; - goto __pyx_L15; - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":814 - * elif t == NPY_LONGLONG: f[0] = 113 #"q" - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" - * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< - * elif t == NPY_DOUBLE: f[0] = 100 #"d" - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" - */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 814, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 814, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 814, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x66; - goto __pyx_L15; - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":815 - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" - * elif t == NPY_FLOAT: f[0] = 102 #"f" - * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf - */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 815, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 815, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 815, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x64; - goto __pyx_L15; - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":816 - * elif t == NPY_FLOAT: f[0] = 102 #"f" - * elif t == NPY_DOUBLE: f[0] = 100 #"d" - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd - */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 816, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 816, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 816, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x67; - goto __pyx_L15; - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":817 - * elif t == NPY_DOUBLE: f[0] = 100 #"d" - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd - * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg - */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 817, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 817, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 817, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 90; - (__pyx_v_f[1]) = 0x66; - __pyx_v_f = (__pyx_v_f + 1); - goto __pyx_L15; - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":818 - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< - * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg - * elif t == NPY_OBJECT: f[0] = 79 #"O" - */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 818, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 818, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 818, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 90; - (__pyx_v_f[1]) = 0x64; - __pyx_v_f = (__pyx_v_f + 1); - goto __pyx_L15; - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":819 - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd - * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< - * elif t == NPY_OBJECT: f[0] = 79 #"O" - * else: - */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 819, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 819, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 819, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 90; - (__pyx_v_f[1]) = 0x67; - __pyx_v_f = (__pyx_v_f + 1); - goto __pyx_L15; - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":820 - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd - * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg - * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) - */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 820, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 820, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 820, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (likely(__pyx_t_6)) { - (__pyx_v_f[0]) = 79; - goto __pyx_L15; - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":822 - * elif t == NPY_OBJECT: f[0] = 79 #"O" - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< - * f += 1 - * else: - */ - /*else*/ { - __pyx_t_3 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 822, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 822, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_Raise(__pyx_t_4, 0, 0, 0); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(2, 822, __pyx_L1_error) - } - __pyx_L15:; - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":823 - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) - * f += 1 # <<<<<<<<<<<<<< - * else: - * # Cython ignores struct boundary information ("T{...}"), - */ - __pyx_v_f = (__pyx_v_f + 1); - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":798 - * offset[0] += child.itemsize - * - * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< - * t = child.type_num - * if end - f < 5: - */ - goto __pyx_L13; - } - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":827 - * # Cython ignores struct boundary information ("T{...}"), - * # so don't output it - * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< - * return f - * - */ - /*else*/ { - __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == ((char *)NULL))) __PYX_ERR(2, 827, __pyx_L1_error) - __pyx_v_f = __pyx_t_9; - } - __pyx_L13:; - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":772 - * cdef tuple fields - * - * for childname in descr.names: # <<<<<<<<<<<<<< - * fields = descr.fields[childname] - * child, new_offset = fields - */ - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":828 - * # so don't output it - * f = _util_dtypestring(child, f, end, offset) - * return f # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = __pyx_v_f; - goto __pyx_L0; - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":763 - * return () - * - * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< - * # Recursive utility function used in __getbuffer__ to get format - * # string. The new location in the format string is returned. - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_child); - __Pyx_XDECREF(__pyx_v_fields); - __Pyx_XDECREF(__pyx_v_childname); - __Pyx_XDECREF(__pyx_v_new_offset); - __Pyx_XDECREF(__pyx_v_t); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":943 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":931 * int _import_umath() except -1 * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< @@ -4147,7 +3337,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("set_array_base", 0); - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":944 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":932 * * cdef inline void set_array_base(ndarray arr, object base): * Py_INCREF(base) # important to do this before stealing the reference below! # <<<<<<<<<<<<<< @@ -4156,7 +3346,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ Py_INCREF(__pyx_v_base); - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":945 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":933 * cdef inline void set_array_base(ndarray arr, object base): * Py_INCREF(base) # important to do this before stealing the reference below! * PyArray_SetBaseObject(arr, base) # <<<<<<<<<<<<<< @@ -4165,7 +3355,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base)); - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":943 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":931 * int _import_umath() except -1 * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< @@ -4177,7 +3367,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a __Pyx_RefNannyFinishContext(); } -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":947 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":935 * PyArray_SetBaseObject(arr, base) * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< @@ -4192,7 +3382,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py int __pyx_t_1; __Pyx_RefNannySetupContext("get_array_base", 0); - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":948 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":936 * * cdef inline object get_array_base(ndarray arr): * base = PyArray_BASE(arr) # <<<<<<<<<<<<<< @@ -4201,7 +3391,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py */ __pyx_v_base = PyArray_BASE(__pyx_v_arr); - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":949 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":937 * cdef inline object get_array_base(ndarray arr): * base = PyArray_BASE(arr) * if base is NULL: # <<<<<<<<<<<<<< @@ -4211,7 +3401,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_t_1 = ((__pyx_v_base == NULL) != 0); if (__pyx_t_1) { - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":950 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":938 * base = PyArray_BASE(arr) * if base is NULL: * return None # <<<<<<<<<<<<<< @@ -4222,7 +3412,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":949 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":937 * cdef inline object get_array_base(ndarray arr): * base = PyArray_BASE(arr) * if base is NULL: # <<<<<<<<<<<<<< @@ -4231,7 +3421,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py */ } - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":951 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":939 * if base is NULL: * return None * return base # <<<<<<<<<<<<<< @@ -4243,7 +3433,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_r = ((PyObject *)__pyx_v_base); goto __pyx_L0; - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":947 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":935 * PyArray_SetBaseObject(arr, base) * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< @@ -4258,7 +3448,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py return __pyx_r; } -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":955 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":943 * # Versions of the import_* functions which are more suitable for * # Cython code. * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< @@ -4282,7 +3472,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { int __pyx_clineno = 0; __Pyx_RefNannySetupContext("import_array", 0); - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":956 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":944 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< @@ -4298,16 +3488,16 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":957 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":945 * cdef inline int import_array() except -1: * try: * __pyx_import_array() # <<<<<<<<<<<<<< * except Exception: * raise ImportError("numpy.core.multiarray failed to import") */ - __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 957, __pyx_L3_error) + __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 945, __pyx_L3_error) - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":956 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":944 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< @@ -4321,7 +3511,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { goto __pyx_L8_try_end; __pyx_L3_error:; - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":958 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":946 * try: * __pyx_import_array() * except Exception: # <<<<<<<<<<<<<< @@ -4331,28 +3521,28 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_4) { __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 958, __pyx_L5_except_error) + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 946, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":959 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":947 * __pyx_import_array() * except Exception: * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< * * cdef inline int import_umath() except -1: */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 959, __pyx_L5_except_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 947, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(2, 959, __pyx_L5_except_error) + __PYX_ERR(2, 947, __pyx_L5_except_error) } goto __pyx_L5_except_error; __pyx_L5_except_error:; - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":956 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":944 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< @@ -4367,7 +3557,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __pyx_L8_try_end:; } - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":955 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":943 * # Versions of the import_* functions which are more suitable for * # Cython code. * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< @@ -4390,7 +3580,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { return __pyx_r; } -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":961 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":949 * raise ImportError("numpy.core.multiarray failed to import") * * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< @@ -4414,7 +3604,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { int __pyx_clineno = 0; __Pyx_RefNannySetupContext("import_umath", 0); - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":962 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":950 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< @@ -4430,16 +3620,16 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":963 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":951 * cdef inline int import_umath() except -1: * try: * _import_umath() # <<<<<<<<<<<<<< * except Exception: * raise ImportError("numpy.core.umath failed to import") */ - __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 963, __pyx_L3_error) + __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 951, __pyx_L3_error) - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":962 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":950 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< @@ -4453,7 +3643,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { goto __pyx_L8_try_end; __pyx_L3_error:; - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":964 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":952 * try: * _import_umath() * except Exception: # <<<<<<<<<<<<<< @@ -4463,28 +3653,28 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_4) { __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 964, __pyx_L5_except_error) + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 952, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":965 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":953 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< * * cdef inline int import_ufunc() except -1: */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 965, __pyx_L5_except_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 953, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(2, 965, __pyx_L5_except_error) + __PYX_ERR(2, 953, __pyx_L5_except_error) } goto __pyx_L5_except_error; __pyx_L5_except_error:; - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":962 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":950 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< @@ -4499,7 +3689,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __pyx_L8_try_end:; } - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":961 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":949 * raise ImportError("numpy.core.multiarray failed to import") * * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< @@ -4522,7 +3712,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { return __pyx_r; } -/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":967 +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":955 * raise ImportError("numpy.core.umath failed to import") * * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< @@ -4546,7 +3736,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { int __pyx_clineno = 0; __Pyx_RefNannySetupContext("import_ufunc", 0); - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":968 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":956 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< @@ -4562,16 +3752,16 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":969 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":957 * cdef inline int import_ufunc() except -1: * try: * _import_umath() # <<<<<<<<<<<<<< * except Exception: * raise ImportError("numpy.core.umath failed to import") */ - __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 969, __pyx_L3_error) + __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 957, __pyx_L3_error) - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":968 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":956 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< @@ -4585,7 +3775,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { goto __pyx_L8_try_end; __pyx_L3_error:; - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":970 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":958 * try: * _import_umath() * except Exception: # <<<<<<<<<<<<<< @@ -4595,28 +3785,28 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_4) { __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 970, __pyx_L5_except_error) + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 958, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":971 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":959 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< * * cdef extern from *: */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 971, __pyx_L5_except_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 959, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(2, 971, __pyx_L5_except_error) + __PYX_ERR(2, 959, __pyx_L5_except_error) } goto __pyx_L5_except_error; __pyx_L5_except_error:; - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":968 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":956 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< @@ -4631,7 +3821,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __pyx_L8_try_end:; } - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":967 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":955 * raise ImportError("numpy.core.umath failed to import") * * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< @@ -4654,6 +3844,180 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { return __pyx_r; } +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":969 + * + * + * cdef inline bint is_timedelta64_object(object obj): # <<<<<<<<<<<<<< + * """ + * Cython equivalent of `isinstance(obj, np.timedelta64)` + */ + +static CYTHON_INLINE int __pyx_f_5numpy_is_timedelta64_object(PyObject *__pyx_v_obj) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("is_timedelta64_object", 0); + + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":981 + * bool + * """ + * return PyObject_TypeCheck(obj, &PyTimedeltaArrType_Type) # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyTimedeltaArrType_Type)); + goto __pyx_L0; + + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":969 + * + * + * cdef inline bint is_timedelta64_object(object obj): # <<<<<<<<<<<<<< + * """ + * Cython equivalent of `isinstance(obj, np.timedelta64)` + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":984 + * + * + * cdef inline bint is_datetime64_object(object obj): # <<<<<<<<<<<<<< + * """ + * Cython equivalent of `isinstance(obj, np.datetime64)` + */ + +static CYTHON_INLINE int __pyx_f_5numpy_is_datetime64_object(PyObject *__pyx_v_obj) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("is_datetime64_object", 0); + + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":996 + * bool + * """ + * return PyObject_TypeCheck(obj, &PyDatetimeArrType_Type) # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyDatetimeArrType_Type)); + goto __pyx_L0; + + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":984 + * + * + * cdef inline bint is_datetime64_object(object obj): # <<<<<<<<<<<<<< + * """ + * Cython equivalent of `isinstance(obj, np.datetime64)` + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":999 + * + * + * cdef inline npy_datetime get_datetime64_value(object obj) nogil: # <<<<<<<<<<<<<< + * """ + * returns the int64 value underlying scalar numpy datetime64 object + */ + +static CYTHON_INLINE npy_datetime __pyx_f_5numpy_get_datetime64_value(PyObject *__pyx_v_obj) { + npy_datetime __pyx_r; + + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":1006 + * also needed. That can be found using `get_datetime64_unit`. + * """ + * return (obj).obval # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = ((PyDatetimeScalarObject *)__pyx_v_obj)->obval; + goto __pyx_L0; + + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":999 + * + * + * cdef inline npy_datetime get_datetime64_value(object obj) nogil: # <<<<<<<<<<<<<< + * """ + * returns the int64 value underlying scalar numpy datetime64 object + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":1009 + * + * + * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil: # <<<<<<<<<<<<<< + * """ + * returns the int64 value underlying scalar numpy timedelta64 object + */ + +static CYTHON_INLINE npy_timedelta __pyx_f_5numpy_get_timedelta64_value(PyObject *__pyx_v_obj) { + npy_timedelta __pyx_r; + + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":1013 + * returns the int64 value underlying scalar numpy timedelta64 object + * """ + * return (obj).obval # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = ((PyTimedeltaScalarObject *)__pyx_v_obj)->obval; + goto __pyx_L0; + + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":1009 + * + * + * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil: # <<<<<<<<<<<<<< + * """ + * returns the int64 value underlying scalar numpy timedelta64 object + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":1016 + * + * + * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: # <<<<<<<<<<<<<< + * """ + * returns the unit part of the dtype for a numpy datetime64 object. + */ + +static CYTHON_INLINE NPY_DATETIMEUNIT __pyx_f_5numpy_get_datetime64_unit(PyObject *__pyx_v_obj) { + NPY_DATETIMEUNIT __pyx_r; + + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":1020 + * returns the unit part of the dtype for a numpy datetime64 object. + * """ + * return (obj).obmeta.base # <<<<<<<<<<<<<< + */ + __pyx_r = ((NPY_DATETIMEUNIT)((PyDatetimeScalarObject *)__pyx_v_obj)->obmeta.base); + goto __pyx_L0; + + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":1016 + * + * + * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: # <<<<<<<<<<<<<< + * """ + * returns the unit part of the dtype for a numpy datetime64 object. + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + /* "ArrayWrapper.pxd":16 * void PyArray_ENABLEFLAGS (np.ndarray array, int flags) * @@ -5006,14 +4370,9 @@ static struct PyModuleDef __pyx_moduledef = { #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0}, - {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0}, {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1}, - {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0}, {&__pyx_n_s_PyGeo2rdr, __pyx_k_PyGeo2rdr, sizeof(__pyx_k_PyGeo2rdr), 0, 0, 1, 1}, - {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, - {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, {&__pyx_n_s_heights, __pyx_k_heights, sizeof(__pyx_k_heights), 0, 0, 1, 1}, @@ -5036,7 +4395,6 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_times, __pyx_k_times, sizeof(__pyx_k_times), 0, 0, 1, 1}, - {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0}, {&__pyx_n_s_vx, __pyx_k_vx, sizeof(__pyx_k_vx), 0, 0, 1, 1}, {&__pyx_n_s_vy, __pyx_k_vy, sizeof(__pyx_k_vy), 0, 0, 1, 1}, {&__pyx_n_s_vz, __pyx_k_vz, sizeof(__pyx_k_vz), 0, 0, 1, 1}, @@ -5047,9 +4405,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { }; static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 2, __pyx_L1_error) - __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(2, 777, __pyx_L1_error) - __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(2, 781, __pyx_L1_error) - __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(2, 959, __pyx_L1_error) + __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(2, 947, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; @@ -5078,60 +4434,27 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":777 - * - * if (end - f) - (new_offset - offset[0]) < 15: - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< - * - * if ((child.byteorder == c'>' and little_endian) or - */ - __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(2, 777, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__3); - __Pyx_GIVEREF(__pyx_tuple__3); - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":781 - * if ((child.byteorder == c'>' and little_endian) or - * (child.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< - * # One could encode it in the format string and have Cython - * # complain instead, BUT: < and > in format strings also imply - */ - __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(2, 781, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__4); - __Pyx_GIVEREF(__pyx_tuple__4); - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":801 - * t = child.type_num - * if end - f < 5: - * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< - * - * # Until ticket #99 is fixed, use integers to avoid warnings - */ - __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(2, 801, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__5); - __Pyx_GIVEREF(__pyx_tuple__5); - - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":959 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":947 * __pyx_import_array() * except Exception: * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< * * cdef inline int import_umath() except -1: */ - __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(2, 959, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__6); - __Pyx_GIVEREF(__pyx_tuple__6); + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(2, 947, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__3); + __Pyx_GIVEREF(__pyx_tuple__3); - /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":965 + /* "../../Miniconda3/envs/RAiDER/lib/python3.7/site-packages/numpy/__init__.pxd":953 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< * * cdef inline int import_ufunc() except -1: */ - __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(2, 965, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__7); - __Pyx_GIVEREF(__pyx_tuple__7); + __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(2, 953, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__4); + __Pyx_GIVEREF(__pyx_tuple__4); __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -5221,18 +4544,38 @@ static int __Pyx_modinit_type_import_code(void) { __Pyx_ImportType_CheckSize_Warn); if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(4, 9, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 207, __pyx_L1_error) + __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 200, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_ptype_5numpy_dtype = __Pyx_ImportType(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __Pyx_ImportType_CheckSize_Ignore); - if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(2, 207, __pyx_L1_error) + if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(2, 200, __pyx_L1_error) __pyx_ptype_5numpy_flatiter = __Pyx_ImportType(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __Pyx_ImportType_CheckSize_Ignore); - if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(2, 230, __pyx_L1_error) + if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(2, 223, __pyx_L1_error) __pyx_ptype_5numpy_broadcast = __Pyx_ImportType(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __Pyx_ImportType_CheckSize_Ignore); - if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(2, 234, __pyx_L1_error) + if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(2, 227, __pyx_L1_error) __pyx_ptype_5numpy_ndarray = __Pyx_ImportType(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __Pyx_ImportType_CheckSize_Ignore); - if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(2, 246, __pyx_L1_error) + if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(2, 239, __pyx_L1_error) + __pyx_ptype_5numpy_generic = __Pyx_ImportType(__pyx_t_1, "numpy", "generic", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_5numpy_generic) __PYX_ERR(2, 771, __pyx_L1_error) + __pyx_ptype_5numpy_number = __Pyx_ImportType(__pyx_t_1, "numpy", "number", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_5numpy_number) __PYX_ERR(2, 773, __pyx_L1_error) + __pyx_ptype_5numpy_integer = __Pyx_ImportType(__pyx_t_1, "numpy", "integer", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_5numpy_integer) __PYX_ERR(2, 775, __pyx_L1_error) + __pyx_ptype_5numpy_signedinteger = __Pyx_ImportType(__pyx_t_1, "numpy", "signedinteger", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_5numpy_signedinteger) __PYX_ERR(2, 777, __pyx_L1_error) + __pyx_ptype_5numpy_unsignedinteger = __Pyx_ImportType(__pyx_t_1, "numpy", "unsignedinteger", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_5numpy_unsignedinteger) __PYX_ERR(2, 779, __pyx_L1_error) + __pyx_ptype_5numpy_inexact = __Pyx_ImportType(__pyx_t_1, "numpy", "inexact", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_5numpy_inexact) __PYX_ERR(2, 781, __pyx_L1_error) + __pyx_ptype_5numpy_floating = __Pyx_ImportType(__pyx_t_1, "numpy", "floating", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_5numpy_floating) __PYX_ERR(2, 783, __pyx_L1_error) + __pyx_ptype_5numpy_complexfloating = __Pyx_ImportType(__pyx_t_1, "numpy", "complexfloating", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_5numpy_complexfloating) __PYX_ERR(2, 785, __pyx_L1_error) + __pyx_ptype_5numpy_flexible = __Pyx_ImportType(__pyx_t_1, "numpy", "flexible", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_5numpy_flexible) __PYX_ERR(2, 787, __pyx_L1_error) + __pyx_ptype_5numpy_character = __Pyx_ImportType(__pyx_t_1, "numpy", "character", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_5numpy_character) __PYX_ERR(2, 789, __pyx_L1_error) __pyx_ptype_5numpy_ufunc = __Pyx_ImportType(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __Pyx_ImportType_CheckSize_Ignore); - if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(2, 839, __pyx_L1_error) + if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(2, 827, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_RefNannyFinishContext(); return 0; @@ -6555,250 +5898,6 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } #endif -/* DictGetItem */ - #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY -static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { - PyObject *value; - value = PyDict_GetItemWithError(d, key); - if (unlikely(!value)) { - if (!PyErr_Occurred()) { - if (unlikely(PyTuple_Check(key))) { - PyObject* args = PyTuple_Pack(1, key); - if (likely(args)) { - PyErr_SetObject(PyExc_KeyError, args); - Py_DECREF(args); - } - } else { - PyErr_SetObject(PyExc_KeyError, key); - } - } - return NULL; - } - Py_INCREF(value); - return value; -} -#endif - -/* RaiseTooManyValuesToUnpack */ - static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { - PyErr_Format(PyExc_ValueError, - "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); -} - -/* RaiseNeedMoreValuesToUnpack */ - static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { - PyErr_Format(PyExc_ValueError, - "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", - index, (index == 1) ? "" : "s"); -} - -/* RaiseNoneIterError */ - static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); -} - -/* PyCFunctionFastCall */ - #if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { - PyCFunctionObject *func = (PyCFunctionObject*)func_obj; - PyCFunction meth = PyCFunction_GET_FUNCTION(func); - PyObject *self = PyCFunction_GET_SELF(func); - int flags = PyCFunction_GET_FLAGS(func); - assert(PyCFunction_Check(func)); - assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))); - assert(nargs >= 0); - assert(nargs == 0 || args != NULL); - /* _PyCFunction_FastCallDict() must not be called with an exception set, - because it may clear it (directly or indirectly) and so the - caller loses its exception */ - assert(!PyErr_Occurred()); - if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { - return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL); - } else { - return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs); - } -} -#endif - -/* PyFunctionFastCall */ - #if CYTHON_FAST_PYCALL -static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, - PyObject *globals) { - PyFrameObject *f; - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject **fastlocals; - Py_ssize_t i; - PyObject *result; - assert(globals != NULL); - /* XXX Perhaps we should create a specialized - PyFrame_New() that doesn't take locals, but does - take builtins without sanity checking them. - */ - assert(tstate != NULL); - f = PyFrame_New(tstate, co, globals, NULL); - if (f == NULL) { - return NULL; - } - fastlocals = __Pyx_PyFrame_GetLocalsplus(f); - for (i = 0; i < na; i++) { - Py_INCREF(*args); - fastlocals[i] = *args++; - } - result = PyEval_EvalFrameEx(f,0); - ++tstate->recursion_depth; - Py_DECREF(f); - --tstate->recursion_depth; - return result; -} -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { - PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); - PyObject *globals = PyFunction_GET_GLOBALS(func); - PyObject *argdefs = PyFunction_GET_DEFAULTS(func); - PyObject *closure; -#if PY_MAJOR_VERSION >= 3 - PyObject *kwdefs; -#endif - PyObject *kwtuple, **k; - PyObject **d; - Py_ssize_t nd; - Py_ssize_t nk; - PyObject *result; - assert(kwargs == NULL || PyDict_Check(kwargs)); - nk = kwargs ? PyDict_Size(kwargs) : 0; - if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { - return NULL; - } - if ( -#if PY_MAJOR_VERSION >= 3 - co->co_kwonlyargcount == 0 && -#endif - likely(kwargs == NULL || nk == 0) && - co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { - if (argdefs == NULL && co->co_argcount == nargs) { - result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); - goto done; - } - else if (nargs == 0 && argdefs != NULL - && co->co_argcount == Py_SIZE(argdefs)) { - /* function called with no arguments, but all parameters have - a default value: use default values as arguments .*/ - args = &PyTuple_GET_ITEM(argdefs, 0); - result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); - goto done; - } - } - if (kwargs != NULL) { - Py_ssize_t pos, i; - kwtuple = PyTuple_New(2 * nk); - if (kwtuple == NULL) { - result = NULL; - goto done; - } - k = &PyTuple_GET_ITEM(kwtuple, 0); - pos = i = 0; - while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { - Py_INCREF(k[i]); - Py_INCREF(k[i+1]); - i += 2; - } - nk = i / 2; - } - else { - kwtuple = NULL; - k = NULL; - } - closure = PyFunction_GET_CLOSURE(func); -#if PY_MAJOR_VERSION >= 3 - kwdefs = PyFunction_GET_KW_DEFAULTS(func); -#endif - if (argdefs != NULL) { - d = &PyTuple_GET_ITEM(argdefs, 0); - nd = Py_SIZE(argdefs); - } - else { - d = NULL; - nd = 0; - } -#if PY_MAJOR_VERSION >= 3 - result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, - args, (int)nargs, - k, (int)nk, - d, (int)nd, kwdefs, closure); -#else - result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, - args, (int)nargs, - k, (int)nk, - d, (int)nd, closure); -#endif - Py_XDECREF(kwtuple); -done: - Py_LeaveRecursiveCall(); - return result; -} -#endif -#endif - -/* PyObjectCallMethO */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { - PyObject *self, *result; - PyCFunction cfunc; - cfunc = PyCFunction_GET_FUNCTION(func); - self = PyCFunction_GET_SELF(func); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = cfunc(self, arg); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); - } - return result; -} -#endif - -/* PyObjectCallOneArg */ - #if CYTHON_COMPILING_IN_CPYTHON -static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_New(1); - if (unlikely(!args)) return NULL; - Py_INCREF(arg); - PyTuple_SET_ITEM(args, 0, arg); - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, &arg, 1); - } -#endif - if (likely(PyCFunction_Check(func))) { - if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { - return __Pyx_PyObject_CallMethO(func, arg); -#if CYTHON_FAST_PYCCALL - } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) { - return __Pyx_PyCFunction_FastCall(func, &arg, 1); -#endif - } - } - return __Pyx__PyObject_CallOneArg(func, arg); -} -#else -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_Pack(1, arg); - if (unlikely(!args)) return NULL; - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -#endif - /* GetTopmostException */ #if CYTHON_USE_EXC_INFO_STACK static _PyErr_StackItem * @@ -7798,24 +6897,31 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { #endif /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { - const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0; + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const long neg_one = (long) -1, const_zero = (long) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { - if (sizeof(int) < sizeof(long)) { + if (sizeof(long) < sizeof(long)) { return PyInt_FromLong((long) value); - } else if (sizeof(int) <= sizeof(unsigned long)) { + } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { - if (sizeof(int) <= sizeof(long)) { + if (sizeof(long) <= sizeof(long)) { return PyInt_FromLong((long) value); #ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); #endif } @@ -7823,7 +6929,7 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(int), + return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); } } @@ -7850,51 +6956,27 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { return (target_type) value;\ } -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) { - const enum NPY_TYPES neg_one = (enum NPY_TYPES) ((enum NPY_TYPES) 0 - (enum NPY_TYPES) 1), const_zero = (enum NPY_TYPES) 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(enum NPY_TYPES) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +/* CIntFromPy */ + static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" #endif - } - } else { - if (sizeof(enum NPY_TYPES) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(enum NPY_TYPES) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); + const long neg_one = (long) -1, const_zero = (long) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop #endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(enum NPY_TYPES), - little, !is_unsigned); - } -} - -/* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { - const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { - if (sizeof(int) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) + if (sizeof(long) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } - return (int) val; + return (long) val; } } else #endif @@ -7903,32 +6985,32 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { - case 0: return (int) 0; - case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) + case 0: return (long) 0; + case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) case 2: - if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { - return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { + return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: - if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { - return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { + return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: - if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { - return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { + return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; @@ -7942,86 +7024,86 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) - return (int) -1; + return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif - if (sizeof(int) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) + if (sizeof(long) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { - case 0: return (int) 0; - case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) + case 0: return (long) 0; + case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) case -2: - if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: - if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: - if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: - if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: - if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: - if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; } #endif - if (sizeof(int) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) + if (sizeof(long) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } @@ -8030,7 +7112,7 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else - int val; + long val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { @@ -8050,71 +7132,47 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { return val; } #endif - return (int) -1; + return (long) -1; } } else { - int val; + long val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (int) -1; - val = __Pyx_PyInt_As_int(tmp); + if (!tmp) return (long) -1; + val = __Pyx_PyInt_As_long(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, - "value too large to convert to int"); - return (int) -1; + "value too large to convert to long"); + return (long) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to int"); - return (int) -1; + "can't convert negative value to long"); + return (long) -1; } -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { - const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(long) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(long) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +/* CIntFromPy */ + static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" #endif - } - } else { - if (sizeof(long) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); + const int neg_one = (int) -1, const_zero = (int) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop #endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(long), - little, !is_unsigned); - } -} - -/* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { - const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { - if (sizeof(long) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) + if (sizeof(int) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } - return (long) val; + return (int) val; } } else #endif @@ -8123,32 +7181,32 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { - case 0: return (long) 0; - case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) + case 0: return (int) 0; + case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) case 2: - if (8 * sizeof(long) > 1 * PyLong_SHIFT) { + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { - return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { + return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: - if (8 * sizeof(long) > 2 * PyLong_SHIFT) { + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { - return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { + return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: - if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { - return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { + return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; @@ -8162,86 +7220,86 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) - return (long) -1; + return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif - if (sizeof(long) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) + if (sizeof(int) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { - case 0: return (long) 0; - case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) + case 0: return (int) 0; + case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) case -2: - if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: - if (8 * sizeof(long) > 1 * PyLong_SHIFT) { + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: - if (8 * sizeof(long) > 2 * PyLong_SHIFT) { + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: - if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } #endif - if (sizeof(long) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) + if (sizeof(int) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } @@ -8250,7 +7308,7 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else - long val; + int val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { @@ -8270,24 +7328,24 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { return val; } #endif - return (long) -1; + return (int) -1; } } else { - long val; + int val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (long) -1; - val = __Pyx_PyInt_As_long(tmp); + if (!tmp) return (int) -1; + val = __Pyx_PyInt_As_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, - "value too large to convert to long"); - return (long) -1; + "value too large to convert to int"); + return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to long"); - return (long) -1; + "can't convert negative value to int"); + return (int) -1; } /* FastTypeChecks */ From 5e44a351a898bbc004fd9d5cc33088465db69cd6 Mon Sep 17 00:00:00 2001 From: bbuzz318 Date: Tue, 20 Jul 2021 12:04:16 -0700 Subject: [PATCH 20/27] remove extra write --- tools/RAiDER/delay.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/RAiDER/delay.py b/tools/RAiDER/delay.py index 357f30f5b..5052d09ae 100755 --- a/tools/RAiDER/delay.py +++ b/tools/RAiDER/delay.py @@ -172,9 +172,6 @@ def tropo_delay(args): # Convert the line-of-sight inputs to look vectors los = getLookVectors(los, lats, lons, hgts, time) - import RAiDER.utilFcns as utilFcns - los_enu = utilFcns.ecef2enu(los, lats, lons, hgts) - np.save('./HR_SV/LOS_ENU.npy', los_enu) # write to an HDF5 file writePnts2HDF5(lats, lons, hgts, los, outName=pnts_file) From 65e7fd6d4a9d4d6d7d37e522d3c5225576f3eb1a Mon Sep 17 00:00:00 2001 From: bbuzz318 Date: Tue, 3 Aug 2021 10:19:43 -0700 Subject: [PATCH 21/27] test fixes from Jeremy --- test/test_util.py | 13 +-- tools/RAiDER/losreader.py | 179 +++++++++++++++++++++++++++----------- 2 files changed, 137 insertions(+), 55 deletions(-) diff --git a/test/test_util.py b/test/test_util.py index d134cd628..31264db60 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -350,37 +350,37 @@ def test_enu2ecef_1(): enu = np.array([0, 0, 1]) llh = np.array([0, 0, 0]) ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) - assert np.allclose(ecef, np.array([_R_EARTH, 0, 0])) + assert np.allclose(ecef, np.array([1, 0, 0])) def test_enu2ecef_2(): enu = np.array([0, 0, 1]) llh = np.array([0, 90, 0]) ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) - assert np.allclose(ecef, np.array([0, _R_EARTH, 0])) + assert np.allclose(ecef, np.array([0, 1, 0])) def test_enu2ecef_3(): enu = np.array([0, 0, 1]) llh = np.array([0, -90, 0]) ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) - assert np.allclose(ecef, np.array([0, -_R_EARTH, 0])) + assert np.allclose(ecef, np.array([0, -1, 0])) def test_enu2ecef_4(): enu = np.array([0, 0, 1]) llh = np.array([90, 0, 0]) ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) - assert np.allclose(ecef, np.array([0, 0, 6356753.31])) + assert np.allclose(ecef, np.array([0, 0, 1])) def test_enu2ecef_5(): enu = np.array([0, 0, 1]) llh = np.array([-90, 0, 0]) ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) - assert np.allclose(ecef, np.array([0, 0, -6356753.31])) + assert np.allclose(ecef, np.array([0, 0, -1])) def test_enu2ecef_6(): enu = np.array([0, 1, 0]) llh = np.array([0, 0, 0]) ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) - assert np.allclose(ecef, np.array([6378137, 0, 1])) + assert np.allclose(ecef, np.array([0, 0, 1])) def test_ecef2enu_1(): @@ -436,3 +436,4 @@ def test_ecef2enu_9(): llh = np.array([0, 180, 0]) ecef = ecef2enu(enu, llh[0], llh[1], llh[2]) assert np.allclose(ecef, np.array([-1, 0, -1])) + diff --git a/tools/RAiDER/losreader.py b/tools/RAiDER/losreader.py index 8411948e2..7760a81b5 100644 --- a/tools/RAiDER/losreader.py +++ b/tools/RAiDER/losreader.py @@ -10,19 +10,23 @@ import datetime import os.path import shelve -import xml.etree.ElementTree as ET +import xml.etree.ElementTree as ET import numpy as np +from scipy.interpolate import interp1d +#from numba import jit + import RAiDER.utilFcns as utilFcns + from RAiDER import Geo2rdr -from RAiDER.constants import _ZREF, Zenith +from RAiDER.constants import _ZREF, Zenith, _RE _SLANT_RANGE_THRESH = 5e6 -def getLookVectors(look_vecs, lats, lons, heights, time=None, pad=3*3600): +def getLookVectors(los_type, lats, lons, heights, zref=_ZREF, time=None, pad=3*3600): ''' Get unit look vectors pointing from the ground (target) pixels to the sensor, or to Zenith. Can be accomplished using an ISCE-style 2-band LOS file or a @@ -49,9 +53,12 @@ def getLookVectors(look_vecs, lats, lons, heights, time=None, pad=3*3600): Returns ------- - look_vecs: ndarray - an x 3 array of unit look vectors, defined in an - Earth-centered, earth-fixed reference frame (ECEF). Convention is - vectors point from the target pixel to the sensor. + look_vecs: ndarray - an x 3 array of unit look vectors, defined in + an Earth-centered, earth-fixed reference frame (ECEF). + Convention is vectors point from the target pixel to the + sensor. + lengths: ndarray - array of of the distnce from the surface to + the top of the troposphere (denoted by zref) Example: -------- @@ -61,18 +68,20 @@ def getLookVectors(look_vecs, lats, lons, heights, time=None, pad=3*3600): >>> getLookVectors(Zenith, np.array([0]), np.array([0]), np.array([0])) >>> # array([[1, 0, 0]]) ''' - if (look_vecs is None) or (look_vecs is Zenith): - look_vecs = Zenith + if (los_type is None) or (los_type is Zenith): + los_type = Zenith else: - look_vecs = look_vecs[1] + los_type = look_vecs[1] in_shape = lats.shape - if look_vecs is Zenith: + if los_type is Zenith: look_vecs = getZenithLookVecs(lats, lons, heights) + lengths = zref - heights else: try: - LOS_enu = inc_hd_to_enu(*utilFcns.gdal_open(look_vecs)) + LOS_enu = inc_hd_to_enu(*utilFcns.gdal_open(los_type)) + lengths = (zref - heights) / utilFcns.cosd(utilFcns.gdal_open(los_type)[0]) look_vecs = utilFcns.enu2ecef( LOS_enu[...,0], LOS_enu[...,1], @@ -84,8 +93,18 @@ def getLookVectors(look_vecs, lats, lons, heights, time=None, pad=3*3600): # if that doesn't work, try parsing as a statevector (orbit) file except OSError: - svs = get_sv(look_vecs, time, pad) - look_vecs = state_to_los(*svs, lats=lats, lons=lons, heights=heights) + svs = np.stack(get_sv(los_type, time, pad), axis=-1) + xyz_targets = np.stack(utilFcns.lla2ecef(lats, lons, heights), axis=-1) + look_vecs = state_to_los( + svs, + xyz_targets, + ) + enu = utilFcns.ecef2enu( + look_vecs, + lats, + lons, + heights) + lengths = (zref - heights) / enu[...,2] # Otherwise, throw an error except: @@ -94,9 +113,10 @@ def getLookVectors(look_vecs, lats, lons, heights, time=None, pad=3*3600): ) mask = (np.isnan(heights) | np.isnan(lats) | np.isnan(lons)) + lengths[mask] = 0. look_vecs[mask, :] = np.nan - return look_vecs.astype(np.float64) + return look_vecs.astype(np.float64), lengths def getZenithLookVecs(lats, lons, heights): @@ -182,7 +202,8 @@ def inc_hd_to_enu(incidence, heading): return np.stack((east, north, up), axis=-1) -def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights): +#@jit(nopython=True) +def state_to_los(svs, xyz_targets): ''' Converts information from a state vector for a satellite orbit, given in terms of position and velocity, to line-of-sight information at each (lon,lat, height) @@ -199,6 +220,7 @@ def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights): Example: >>> import datetime + >>> import numpy >>> from RAiDER.utilFcns import gdal_open >>> import RAiDER.losreader as losr >>> lats, lons, heights = np.array([-76.1]), np.array([36.83]), np.array([0]) @@ -210,47 +232,28 @@ def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights): ''' # check the inputs - if t.size < 4: + if np.min(svs.shape)< 4: raise RuntimeError( 'state_to_los: At least 4 state vectors are required' ' for orbit interpolation' ) - if t.shape != x.shape: - raise RuntimeError('state_to_los: t and x must be the same size') - if lats.shape != lons.shape: - raise RuntimeError('state_to_los: lats and lons must be the same size') - - in_shape = lats.shape - geo2rdr_obj = Geo2rdr.PyGeo2rdr() - geo2rdr_obj.set_orbit(t, x, y, z, vx, vy, vz) - - los_x, los_y, los_z = [], [], [] - for i, (l, L, h) in enumerate(zip(lats.ravel(), lons.ravel(), heights.ravel())): - # Geo2rdr is picky about how the heights look - height_array = np.array(((h,),)).astype(np.double) - # Set the target pixel location - geo2rdr_obj.set_geo_coordinate(np.radians(L), np.radians(l), 1, 1, height_array) + # Flatten the input array for convenience + in_shape = xyz_targets.shape + target_xyz = np.stack([xyz_targets[...,0].flatten(), xyz_targets[...,1].flatten(), xyz_targets[...,2].flatten()], axis=-1) + Npts = len(target_xyz) - # compute the look vector and target-sensor range in ECEF - geo2rdr_obj.geo2rdr() - - # get back the line of sight unit vector - # LOS is defined as pointing from the ground pixel to the sensor - los = np.squeeze(geo2rdr_obj.get_los()) - los_x.append(los[0]) - los_y.append(los[1]) - los_z.append(los[2]) - - los_ecef = np.stack([ - np.array(los_x).reshape(in_shape), - np.array(los_y).reshape(in_shape), - np.array(los_z).reshape(in_shape), - ], axis=-1) + # Iterate through targets and compute LOS + slant_range = [] + los = np.empty((Npts, 3), dtype=np.float64) + breakpoint() + for k in range(Npts): + los[k,:], sr = get_radar_coordinate(target_xyz[k,:], svs) + slant_range.append(sr) + slant_ranges = np.array(slant_range) # Sanity check for purpose of tracking problems - # print ('Slant range', geo2rdr_obj.get_slant_range()) - if geo2rdr_obj.get_slant_range() > _SLANT_RANGE_THRESH: + if slant_ranges.max() > _SLANT_RANGE_THRESH: raise RuntimeError( ''' state_to_los: @@ -261,8 +264,8 @@ def state_to_los(t, x, y, z, vx, vy, vz, lats, lons, heights): the same range of time. ''' ) - del geo2rdr_obj + los_ecef = los.reshape(in_shape) return los_ecef @@ -291,6 +294,9 @@ def read_shelve(filename): obj = db['frame'] numSV = len(obj.orbit.stateVectors) + breakpoint() + if numSV==0: + raise ValueError('read_shelve: the file has not statevectors') t = np.ones(numSV) x = np.ones(numSV) @@ -352,6 +358,10 @@ def read_txt_file(filename): vx.append(vx_) vy.append(vy_) vz.append(vz_) + + if len(t) < 4: + raise ValueError('read_txt_file: File {} does not have enough statevectors'.format(filename)) + return [np.array(a) for a in [t, x, y, z, vx, vy, vz]] @@ -402,3 +412,74 @@ def read_ESA_Orbit_file(filename, ref_time): vz[i] = float(st[9].text) return [t, x, y, z, vx, vy, vz] + + +#@jit(nopython=True) +def get_radar_coordinate(xyz, svs, t0=None): + ''' + Calculate the coordinate of the sensor in ECEF at the time corresponding to ***. + + Parameters + ---------- + svs: ndarray - Nt x 7 matrix of statevectors: [t x y z vx vy vz] + xyz: ndarray - position of the target in ECEF + t0: double - starting point of the time at which the sensor imaged the target xyz + + Returns + ------- + sensor_xyz: ndarray - position of the sensor in ECEF + ''' + # initialize search + if t0 is None: + t = (svs[:,0].max() - svs[:,0].min()) / 2 + else: + t = t0 + + dt = 1.0 + num_iteration = 20 + residual_threshold = 0.000000001 + + dts = [] + for k in range(num_iteration): + x = interpolate(svs[:,0], svs[:,1], t) + y = interpolate(svs[:,0], svs[:,2], t) + z = interpolate(svs[:,0], svs[:,3], t) + vx = interpolate(svs[:,0], svs[:,4], t) + vy = interpolate(svs[:,0], svs[:,5], t) + vz = interpolate(svs[:,0], svs[:,6], t) + E1 = vx*(xyz[0] - x) + vy*(xyz[1] - y) + vz*(xyz[2] - z) + dE1 = vx*vx + vy*vy + vz*vz + dt = E1/dE1; + dts.append(dt) + t = t+dt; + if np.abs(dt) < residual_threshold: + break + + los_x = xyz[0] - x + los_y = xyz[1] - y + los_z = xyz[2] - z + + slant_range = np.sqrt( + np.square(los_x) + np.square(los_y) + np.square(los_z) + ); + breakpoint() + return np.array([los_x, los_y, los_z]) / slant_range, slant_range + + +def interpolate(t, var, tq): + ''' + Interpolate a set of statevectors to the requested input time + + Parameters + ---------- + statevectors: ndarray - an Nt x 7 matrix of statevectors: [t x y z vx vy vz] + tref: double - reference time requested (must be in the scope of t) + + Returns + ------- + x, y, z: double - sensor position in ECEF + vx, vy, vz: double - sensor velocity + ''' + f = interp1d(t, var) + return f(tq) + From 9a039b1609c1923d81dfa83a04b8409d7cc9b947 Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Fri, 6 Aug 2021 14:04:49 -0500 Subject: [PATCH 22/27] Fix call to getLookVectors --- tools/RAiDER/delay.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/RAiDER/delay.py b/tools/RAiDER/delay.py index 5052d09ae..3f6669ed9 100755 --- a/tools/RAiDER/delay.py +++ b/tools/RAiDER/delay.py @@ -171,7 +171,7 @@ def tropo_delay(args): logger.debug('Beginning line-of-sight calculation') # Convert the line-of-sight inputs to look vectors - los = getLookVectors(los, lats, lons, hgts, time) + los = getLookVectors(los, lats, lons, hgts, zref = zref, time = time) # write to an HDF5 file writePnts2HDF5(lats, lons, hgts, los, outName=pnts_file) From 86af6dc095491e181f082d2533a4978026ad48a9 Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Fri, 6 Aug 2021 14:32:44 -0500 Subject: [PATCH 23/27] Fix some bugs and make sure los vars get carried through correctly --- test/test_scenario_1.py | 9 --- tools/RAiDER/delay.py | 4 +- tools/RAiDER/delayFcns.py | 4 +- tools/RAiDER/losreader.py | 4 +- tools/RAiDER/utilFcns.py | 145 ++++++++++++++++++++++++-------------- 5 files changed, 98 insertions(+), 68 deletions(-) diff --git a/test/test_scenario_1.py b/test/test_scenario_1.py index 394e667c6..6fece56bd 100755 --- a/test/test_scenario_1.py +++ b/test/test_scenario_1.py @@ -44,15 +44,6 @@ def test_tropo_delay_ERA5T(tmp_path): core_test_tropo_delay(tmp_path, modelName="ERA5T") -@pytest.mark.timeout(600) -def test_tropo_delay_HRES(tmp_path): - ''' - Scenario: - 1: Small area, HRES, Zenith delay - ''' - core_test_tropo_delay(tmp_path, modelName="HRES") - - @pytest.mark.timeout(600) def test_tropo_delay_GMAO(tmp_path): ''' diff --git a/tools/RAiDER/delay.py b/tools/RAiDER/delay.py index 3f6669ed9..e1e1530fd 100755 --- a/tools/RAiDER/delay.py +++ b/tools/RAiDER/delay.py @@ -171,10 +171,10 @@ def tropo_delay(args): logger.debug('Beginning line-of-sight calculation') # Convert the line-of-sight inputs to look vectors - los = getLookVectors(los, lats, lons, hgts, zref = zref, time = time) + los,lengths = getLookVectors(los, lats, lons, hgts, zref = zref, time = time) # write to an HDF5 file - writePnts2HDF5(lats, lons, hgts, los, outName=pnts_file) + writePnts2HDF5(lats, lons, hgts, los, lengths, outName=pnts_file) else: logger.warning( diff --git a/tools/RAiDER/delayFcns.py b/tools/RAiDER/delayFcns.py index 1fc958193..2faac5c62 100755 --- a/tools/RAiDER/delayFcns.py +++ b/tools/RAiDER/delayFcns.py @@ -55,7 +55,7 @@ def calculate_rays(pnts_file, stepSize=_STEP): with h5py.File(pnts_file, 'r+') as f: f['Rays_SP'][...] = sp.astype(np.float64) # ensure double is maintained - f['Rays_SLV'][...] = los + f['LOS'][...] = los f['Rays_len'][:] = lengths.astype(np.float64) f['Rays_len'].attrs['MaxLen'] = np.nanmax(lengths) @@ -91,7 +91,7 @@ def get_delays( Nchunks = len(CHUNKS) with h5py.File(pnts_file, 'r') as f: - chunk_inputs = [(kk, CHUNKS[kk], np.array(f['Rays_SP']), np.array(f['Rays_SLV']), + chunk_inputs = [(kk, CHUNKS[kk], np.array(f['Rays_SP']), np.array(f['LOS']), chunkSize, stepSize, ifWet, ifHydro, max_len, wm_file) for kk in range(Nchunks)] if Nchunks == 1: diff --git a/tools/RAiDER/losreader.py b/tools/RAiDER/losreader.py index 7760a81b5..3c8b769ed 100644 --- a/tools/RAiDER/losreader.py +++ b/tools/RAiDER/losreader.py @@ -39,7 +39,7 @@ def getLookVectors(los_type, lats, lons, heights, zref=_ZREF, time=None, pad=3* Parameters ---------- - look_vecs: LookVector object or tuple - Either a Zenith object or a tuple, + los_type: LookVector object or tuple - Either a Zenith object or a tuple, with the second element containing the name of either a line-of-sight file or orbital statevectors file @@ -71,7 +71,7 @@ def getLookVectors(los_type, lats, lons, heights, zref=_ZREF, time=None, pad=3* if (los_type is None) or (los_type is Zenith): los_type = Zenith else: - los_type = look_vecs[1] + los_type = los_type[1] in_shape = lats.shape diff --git a/tools/RAiDER/utilFcns.py b/tools/RAiDER/utilFcns.py index 449f5eb28..3619baf2b 100755 --- a/tools/RAiDER/utilFcns.py +++ b/tools/RAiDER/utilFcns.py @@ -2,18 +2,21 @@ import multiprocessing as mp import os import re + from datetime import datetime, timedelta import h5py import numpy as np +from numpy import ndarray import pandas as pd import pyproj +from pyproj import CRS, Transformer from osgeo import gdal, osr import progressbar from RAiDER.constants import ( - Zenith, - _g0 as g0, + Zenith, + _g0 as g0, _RE as Re, R_EARTH_MAX as Rmax, R_EARTH_MIN as Rmin, @@ -39,13 +42,42 @@ def cosd(x): def lla2ecef(lat, lon, height): - ecef = pyproj.Proj(proj='geocent') - lla = pyproj.Proj(proj='latlong') + T = Transformer.from_crs(4326, 4978) - return pyproj.transform(lla, ecef, lon, lat, height, always_xy=True) + return T.transform(lon, lat, height) + + +def enu2ecef( + east: ndarray, + north: ndarray, + up: ndarray, + lat0: ndarray, + lon0: ndarray, + ): + """ + Parameters + ---------- + e1 : float + target east ENU coordinate (meters) + n1 : float + target north ENU coordinate (meters) + u1 : float + target up ENU coordinate (meters) + Results + ------- + u : float + v : float + w : float + """ + t = cosd(lat0) * up - sind(lat0) * north + w = sind(lat0) * up + cosd(lat0) * north + + u = cosd(lon0) * t - sind(lon0) * east + v = sind(lon0) * t + cosd(lon0) * east + + return np.stack((u, v, w),axis=-1) - def ecef2enu(xyz, lat, lon, height): '''Convert ECEF xyz to ENU''' x, y, z = xyz[...,0],xyz[...,1],xyz[...,2] @@ -57,29 +89,6 @@ def ecef2enu(xyz, lat, lon, height): u = cosd(lat) * t + sind(lat) * z return np.stack((e, n, u), axis=-1) -def enu2ecef(east, north, up, lat0, lon0, h0): - """Return ecef from enu coordinates.""" - # I'm looking at - # https://github.com/scivision/pymap3d/blob/master/pymap3d/__init__.py - # x0, y0, z0 = lla2ecef(lat0, lon0, h0) - - x = cosd(lon0) * cosd(lat0) * up - cosd(lon0) *sind(lat0) * north - sind(lon0) * east - y = sind(lon0) * cosd(lat0) * up - sind(lon0) *sind(lat0) * north + cosd(lon0) * east - z = sind(lat0) * up + cosd(lat0) * north - - # my_ecef = np.stack((x0 + u, y0 + v, z0 + w), axis=-1) - my_ecef = np.stack((x, y, z), axis=-1) - - return my_ecef - -def getRotMatrix(lat, lon): - '''Rotation matrix for geographic transformations''' - return np.array([ - [-sind(lon), cosd(lon), 0], - [-cosd(lon)*sind(lat), -sind(lon)*sind(lat), cosd(lat)], - [cosd(lon)*cosd(lat), sind(lon)*cosd(lat), sind(lat)] - ]) - def gdal_extents(fname): if os.path.exists(fname + '.vrt'): @@ -273,7 +282,7 @@ def _geo_to_ht(lats, hts): # Calculate Geometric Height, h h = (hts * Re) / (g_ll / g0 * Re - hts) - # from metpy + # from metpy # return (geopotential * Re) / (g0 * Re - geopotential) return h @@ -412,27 +421,24 @@ def getTimeFromFile(filename): raise RuntimeError('The filename for {} does not include a datetime in the correct format'.format(filename)) -def writePnts2HDF5(lats, lons, hgts, los, outName='testx.h5', chunkSize=None, noDataValue=0.): +def writePnts2HDF5(lats, lons, hgts, los, lengths, outName='testx.h5', chunkSize=None, noDataValue=0., epsg=4326): ''' Write query points to an HDF5 file for storage and access ''' - epsg = 4326 projname = 'projection' + # converts from WGS84 geodetic to WGS84 geocentric + t = Transformer.from_crs(epsg, 4978, always_xy=True) + checkLOS(los, np.prod(lats.shape)) in_shape = lats.shape # create directory if needed os.makedirs(os.path.abspath(os.path.dirname(outName)), exist_ok=True) + # Set up the chunking if chunkSize is None: - minChunkSize = 100 - maxChunkSize = 1000 - cpu_count = mp.cpu_count() - chunkSize = tuple(max(min(maxChunkSize, s // cpu_count), min(s, minChunkSize)) for s in in_shape) - - logger.debug('Chunk size is {}'.format(chunkSize)) - logger.debug('Array shape is {}'.format(in_shape)) + chunkSize = getChunkSize(in_shape) with h5py.File(outName, 'w') as f: f.attrs['Conventions'] = np.string_("CF-1.8") @@ -440,10 +446,33 @@ def writePnts2HDF5(lats, lons, hgts, los, outName='testx.h5', chunkSize=None, no x = f.create_dataset('lon', data=lons, chunks=chunkSize, fillvalue=noDataValue) y = f.create_dataset('lat', data=lats, chunks=chunkSize, fillvalue=noDataValue) z = f.create_dataset('hgt', data=hgts, chunks=chunkSize, fillvalue=noDataValue) - los = f.create_dataset('LOS', data=los, chunks=chunkSize + (3,), fillvalue=noDataValue) + los = f.create_dataset( + 'LOS', + data=los, + chunks=chunkSize + (3,), + fillvalue=noDataValue + ) + lengths = f.create_dataset( + 'Rays_len', + data=lengths, + chunks=x.chunks, + fillvalue=noDataValue + ) + sp_data = np.stack(t.transform(lons, lats, hgts), axis=-1).astype(np.float64) + sp = f.create_dataset( + 'Rays_SP', + data=sp_data, + chunks=chunkSize + (3,), + fillvalue=noDataValue + ) + x.attrs['Shape'] = in_shape y.attrs['Shape'] = in_shape z.attrs['Shape'] = in_shape + los.attrs['Shape'] = in_shape + (3,) + lengths.attrs['Shape'] = in_shape + lengths.attrs['Units'] = 'm' + sp.attrs['Shape'] = in_shape + (3,) f.attrs['ChunkSize'] = chunkSize f.attrs['NoDataValue'] = noDataValue @@ -475,14 +504,9 @@ def writePnts2HDF5(lats, lons, hgts, los, outName='testx.h5', chunkSize=None, no else: raise NotImplemented - start_positions = f.create_dataset('Rays_SP', in_shape + (3,), chunks=los.chunks, dtype=' Date: Fri, 6 Aug 2021 15:30:32 -0500 Subject: [PATCH 24/27] Fix unit tests for GMAO and a few bugs --- test/scenario_1/GMAO/hydro.envi | Bin 660 -> 660 bytes test/scenario_1/GMAO/hydro.hdr | 5 +++++ test/scenario_1/GMAO/wet.envi | Bin 660 -> 660 bytes test/scenario_1/GMAO/wet.hdr | 5 +++++ test/test_scenario_2.py | 15 +++------------ tools/RAiDER/delayFcns.py | 15 --------------- tools/RAiDER/utilFcns.py | 2 ++ 7 files changed, 15 insertions(+), 27 deletions(-) diff --git a/test/scenario_1/GMAO/hydro.envi b/test/scenario_1/GMAO/hydro.envi index feaf348a5832b4ab7ed9100a4addc17b3deef2f1..87196ab9d7968f073a547cf568506ae9c981c08d 100644 GIT binary patch delta 16 XcmbQjI)!yZ1QUx>0=L8D7$yq Date: Fri, 6 Aug 2021 15:34:58 -0500 Subject: [PATCH 25/27] autopep8 fixes --- test/test_checkArgs.py | 58 +++++++- test/test_losreader.py | 166 +++++++++++++---------- test/test_scenario_1.py | 4 +- test/test_scenario_2.py | 3 +- test/test_util.py | 24 +++- test/weather_model/test_weather_model.py | 4 +- tools/RAiDER/checkArgs.py | 2 - tools/RAiDER/constants.py | 1 + tools/RAiDER/delay.py | 3 +- tools/RAiDER/gnss/processDelayFiles.py | 74 +++++----- tools/RAiDER/losreader.py | 69 +++++----- tools/RAiDER/models/ecmwf.py | 27 ++-- tools/RAiDER/models/era5.py | 4 +- tools/RAiDER/models/hres.py | 15 +- tools/RAiDER/models/model_levels.py | 2 - tools/RAiDER/models/ncmr.py | 30 ++-- tools/RAiDER/models/weatherModel.py | 5 +- tools/RAiDER/processWM.py | 2 +- tools/RAiDER/statsPlot.py | 36 ++--- tools/RAiDER/utilFcns.py | 77 +++++------ 20 files changed, 332 insertions(+), 274 deletions(-) diff --git a/test/test_checkArgs.py b/test/test_checkArgs.py index a4da36982..c23c39ec0 100644 --- a/test/test_checkArgs.py +++ b/test/test_checkArgs.py @@ -22,12 +22,13 @@ def isWriteable(dirpath): '''Test whether a directory is writeable''' try: - filehandle = open(os.path.join(dirpath, 'tmp.txt'), 'w' ) + filehandle = open(os.path.join(dirpath, 'tmp.txt'), 'w') filehandle.close() return True except IOError: return False - + + @pytest.fixture def parsed_args(tmp_path): parser = RAiDER.runProgram.create_parser() @@ -50,6 +51,7 @@ def test_checkArgs_outfmt_1(parsed_args): checkArgs(args, p) assert True + def test_checkArgs_outfmt_2(parsed_args): '''Test that passing a raster format with height levels throws an error''' args, p = parsed_args @@ -58,6 +60,7 @@ def test_checkArgs_outfmt_2(parsed_args): with pytest.raises(ValueError): checkArgs(args, p) + def test_checkArgs_outfmt_3(parsed_args): '''Test that passing a raster format with height levels throws an error''' args, p = parsed_args @@ -65,6 +68,7 @@ def test_checkArgs_outfmt_3(parsed_args): argDict = checkArgs(args, p) assert argDict['flag'] == 'station_file' + def test_checkArgs_outfmt_4(parsed_args): '''Test that passing a raster format with height levels throws an error''' args, p = parsed_args @@ -72,6 +76,7 @@ def test_checkArgs_outfmt_4(parsed_args): argDict = checkArgs(args, p) assert argDict['flag'] == 'files' + def test_checkArgs_outloc_1(parsed_args): '''Test that the default output and weather model directories are correct''' args, p = parsed_args @@ -81,6 +86,7 @@ def test_checkArgs_outloc_1(parsed_args): assert os.path.abspath(out) == os.getcwd() assert os.path.abspath(wmLoc) == os.path.join(os.getcwd(), 'weather_files') + def test_checkArgs_outloc_2(parsed_args, tmp_path): '''Tests that the correct output location gets assigned when provided''' with pushd(tmp_path): @@ -90,6 +96,7 @@ def test_checkArgs_outloc_2(parsed_args, tmp_path): out = argDict['out'] assert out == tmp_path + def test_checkArgs_outloc_2b(parsed_args, tmp_path): ''' Tests that the weather model directory gets passed through by itself''' with pushd(tmp_path): @@ -99,12 +106,14 @@ def test_checkArgs_outloc_2b(parsed_args, tmp_path): argDict = checkArgs(args, p) assert argDict['wmLoc'] == 'weather_dir' + def test_checkArgs_outloc_3(parsed_args): '''Tests that the weather model directory gets created when needed''' args, p = parsed_args argDict = checkArgs(args, p) assert os.path.isdir(argDict['wmLoc']) + def test_checkArgs_outloc_4(parsed_args): '''Tests for creating writeable weather model directory''' args, p = parsed_args @@ -112,6 +121,7 @@ def test_checkArgs_outloc_4(parsed_args): assert isWriteable(argDict['wmLoc']) + def test_ll_bounds_1(parsed_args): '''Tests that lats out of bounds raises error''' args, p = parsed_args @@ -119,6 +129,7 @@ def test_ll_bounds_1(parsed_args): with pytest.raises(ValueError): checkArgs(args, p) + def test_ll_bounds_2(parsed_args): '''Tests that lats out of bounds raises error''' args, p = parsed_args @@ -126,6 +137,7 @@ def test_ll_bounds_2(parsed_args): with pytest.raises(ValueError): checkArgs(args, p) + def test_los_1(parsed_args): '''Tests that lats out of bounds raises error''' args, p = parsed_args @@ -134,6 +146,7 @@ def test_los_1(parsed_args): assert argDict['los'][0] == 'los' assert argDict['los'][1] == 'los.rdr' + def test_los_2(parsed_args): '''Tests that lats out of bounds raises error''' args, p = parsed_args @@ -142,12 +155,14 @@ def test_los_2(parsed_args): assert argDict['los'][0] == 'sv' assert argDict['los'][1] == 'sv.txt' + def test_los_3(parsed_args): '''Tests that lats out of bounds raises error''' args, p = parsed_args argDict = checkArgs(args, p) assert argDict['los'] == Zenith + def test_models_1a(parsed_args): '''Tests that the weather model gets passed through correctly''' args, p = parsed_args @@ -155,6 +170,7 @@ def test_models_1a(parsed_args): assert argDict['weather_model']['type'].Model() == 'ERA-5' assert argDict['weather_model']['name'] == 'era5' + def test_models_1b(parsed_args): '''Tests that the weather model gets passed through correctly''' args, p = parsed_args @@ -163,6 +179,7 @@ def test_models_1b(parsed_args): assert argDict['weather_model']['type'].Model() == 'HRRR' assert argDict['weather_model']['name'] == 'hrrr' + def test_models_1c(parsed_args): '''Tests that the weather model gets passed through correctly''' args, p = parsed_args @@ -171,6 +188,7 @@ def test_models_1c(parsed_args): assert argDict['weather_model']['type'].Model() == 'NCMR' assert argDict['weather_model']['name'] == 'ncmr' + def test_models_1d(parsed_args): '''Tests that the weather model gets passed through correctly''' args, p = parsed_args @@ -179,6 +197,7 @@ def test_models_1d(parsed_args): assert argDict['weather_model']['type'].Model() == 'ERA-5' assert argDict['weather_model']['name'] == 'era5' + def test_models_1e(parsed_args): '''Tests that the weather model gets passed through correctly''' args, p = parsed_args @@ -187,6 +206,7 @@ def test_models_1e(parsed_args): assert argDict['weather_model']['type'].Model() == 'ERA-5' assert argDict['weather_model']['name'] == 'era5' + def test_models_1f(parsed_args): '''Tests that the weather model gets passed through correctly''' args, p = parsed_args @@ -195,6 +215,7 @@ def test_models_1f(parsed_args): assert argDict['weather_model']['type'].Model() == 'ERA-5' assert argDict['weather_model']['name'] == 'era5' + def test_models_2(parsed_args): '''Tests that unknown weather models get rejected''' args, p = parsed_args @@ -202,6 +223,7 @@ def test_models_2(parsed_args): with pytest.raises(NotImplementedError): checkArgs(args, p) + def test_models_3a(parsed_args): '''Tests that WRF weather models requires files''' args, p = parsed_args @@ -209,6 +231,7 @@ def test_models_3a(parsed_args): with pytest.raises(RuntimeError): checkArgs(args, p) + def test_models_3b(parsed_args): '''Tests that HDF5 weather models requires files''' args, p = parsed_args @@ -216,6 +239,7 @@ def test_models_3b(parsed_args): with pytest.raises(RuntimeError): checkArgs(args, p) + def test_models_3c(parsed_args): '''Tests that WRF weather models requires files''' args, p = parsed_args @@ -224,12 +248,14 @@ def test_models_3c(parsed_args): argDict = checkArgs(args, p) assert True + def test_zref_1(parsed_args): '''tests that default zref gets generated''' args, p = parsed_args argDict = checkArgs(args, p) assert argDict['zref'] == _ZREF + def test_zref_2(parsed_args): '''tests that default zref gets generated''' ztest = 20000 @@ -238,11 +264,13 @@ def test_zref_2(parsed_args): argDict = checkArgs(args, p) assert argDict['zref'] == ztest + def test_parallel_1(parsed_args): '''tests that parallel options are handled correctly''' args, p = parsed_args argDict = checkArgs(args, p) - assert argDict['parallel'] == 1 + assert argDict['parallel'] == 1 + def test_parallel_2(parsed_args): '''tests that parallel options are handled correctly''' @@ -251,12 +279,14 @@ def test_parallel_2(parsed_args): argDict = checkArgs(args, p) assert argDict['parallel'] == mp.cpu_count() + def test_parallel_3(parsed_args): '''tests that parallel options are handled correctly''' args, p = parsed_args args.parallel = 2 argDict = checkArgs(args, p) - assert argDict['parallel'] == 2 + assert argDict['parallel'] == 2 + def test_parallel_4(parsed_args): '''tests that parallel options are handled correctly''' @@ -265,12 +295,14 @@ def test_parallel_4(parsed_args): argDict = checkArgs(args, p) assert argDict['parallel'] == mp.cpu_count() + def test_verbose_1(parsed_args): '''tests that verbose option is handled correctly''' args, p = parsed_args argDict = checkArgs(args, p) assert not argDict['verbose'] + def test_verbose_2(parsed_args): '''tests that verbose option is handled correctly''' args, p = parsed_args @@ -278,12 +310,14 @@ def test_verbose_2(parsed_args): argDict = checkArgs(args, p) assert argDict['verbose'] + def test_download_only_1(parsed_args): '''tests that the download-only option is handled correctly''' args, p = parsed_args argDict = checkArgs(args, p) assert not argDict['download_only'] + def test_download_only_2(parsed_args): '''tests that the download-only option is handled correctly''' args, p = parsed_args @@ -291,11 +325,13 @@ def test_download_only_2(parsed_args): argDict = checkArgs(args, p) assert argDict['download_only'] + def test_useWeatherNodes_1(parsed_args): '''tests that the correct flag gets passed''' args, p = parsed_args argDict = checkArgs(args, p) - assert argDict['flag'] == 'bounding_box'# default arguments use a bounding box + assert argDict['flag'] == 'bounding_box' # default arguments use a bounding box + def test_filenames_1(parsed_args): '''tests that the correct filenames are generated''' @@ -308,6 +344,7 @@ def test_filenames_1(parsed_args): assert '20200103' in argDict['hydroFilenames'][0] assert len(argDict['hydroFilenames']) == 1 + def test_filenames_2(parsed_args): '''tests that the correct filenames are generated''' args, p = parsed_args @@ -317,14 +354,17 @@ def test_filenames_2(parsed_args): assert '20200103' in argDict['wetFilenames'][0] assert len(argDict['wetFilenames']) == 1 + def test_makeDelayFileNames_1(): assert makeDelayFileNames(None, None, "h5", "name", "dir") == \ ("dir/name_wet_ztd.h5", "dir/name_hydro_ztd.h5") + def test_makeDelayFileNames_2(): assert makeDelayFileNames(None, (), "h5", "name", "dir") == \ ("dir/name_wet_std.h5", "dir/name_hydro_std.h5") + def test_makeDelayFileNames_3(): assert makeDelayFileNames(datetime.datetime(2020, 1, 1, 1, 2, 3), None, "h5", "model_name", "dir") == \ ( @@ -332,6 +372,7 @@ def test_makeDelayFileNames_3(): "dir/model_name_hydro_20200101T010203_ztd.h5" ) + def test_makeDelayFileNames_4(): assert makeDelayFileNames(datetime.datetime(1900, 12, 31, 1, 2, 3), "los", "h5", "model_name", "dir") == \ ( @@ -339,10 +380,12 @@ def test_makeDelayFileNames_4(): "dir/model_name_hydro_19001231T010203_std.h5" ) + def test_model2module(): model_module_name, model_obj = modelName2Module('ERA5') assert model_obj().Model() == 'ERA-5' + def test_dem_1(parsed_args): '''Test that passing a raster format with height levels throws an error''' args, p = parsed_args @@ -350,6 +393,7 @@ def test_dem_1(parsed_args): assert argDict['heights'][0] == 'skip' assert argDict['heights'][1] is None + def test_dem_2(parsed_args): '''Test that passing a raster format with height levels throws an error''' args, p = parsed_args @@ -358,6 +402,7 @@ def test_dem_2(parsed_args): assert argDict['heights'][0] == 'lvs' assert np.allclose(argDict['heights'][1], [10, 100, 1000]) + def test_dem_3(parsed_args): '''Test that passing a raster format with height levels throws an error''' args, p = parsed_args @@ -367,6 +412,7 @@ def test_dem_3(parsed_args): assert argDict['heights'][0] == 'lvs' assert np.allclose(argDict['heights'][1], [10, 100, 1000]) + def test_dem_4(parsed_args): '''Test that passing a raster format with height levels throws an error''' args, p = parsed_args @@ -375,6 +421,7 @@ def test_dem_4(parsed_args): assert argDict['heights'][0] == 'pandas' assert argDict['heights'][1][0] == argDict['wetFilenames'][0] + def test_dem_5(parsed_args): '''Test that passing a raster format with height levels throws an error''' args, p = parsed_args @@ -382,4 +429,3 @@ def test_dem_5(parsed_args): argDict = checkArgs(args, p) assert argDict['heights'][0] == 'download' assert argDict['heights'][1] == os.path.join(argDict['out'], 'geom', 'warpedDEM.dem') - diff --git a/test/test_losreader.py b/test/test_losreader.py index 129bc8fa5..0790baac5 100644 --- a/test/test_losreader.py +++ b/test/test_losreader.py @@ -33,63 +33,63 @@ def svs(): tr = np.array([(t - ref_time).total_seconds() for t in T]) x = np.array([ -2064965.285362, - -2056228.553736, - -2047224.526705, - -2037955.293282, - -2028422.977002, - -2018629.735564, - -2008577.760461, - -1998269.276601, + -2056228.553736, + -2047224.526705, + -2037955.293282, + -2028422.977002, + -2018629.735564, + -2008577.760461, + -1998269.276601, ]) y = np.array([ 6434865.494987, - 6460407.492520, - 6485212.031660, - 6509275.946120, - 6532596.156540, - 6555169.670917, - 6576993.585012, - 6598065.082739, + 6460407.492520, + 6485212.031660, + 6509275.946120, + 6532596.156540, + 6555169.670917, + 6576993.585012, + 6598065.082739, ]) z = np.array([ - 2090670.967443, - 2019650.417312, - 1948401.684024, - 1876932.818066, - 1805251.894958, - 1733367.014327, - 1661286.298987, - 1589017.893976, + 2090670.967443, + 2019650.417312, + 1948401.684024, + 1876932.818066, + 1805251.894958, + 1733367.014327, + 1661286.298987, + 1589017.893976, ]) vx = np.array([ - 860.239634, - 887.072466, - 913.698134, - 940.113169, - 966.314136, - 992.297636, - 1018.060311, - 1043.598837, + 860.239634, + 887.072466, + 913.698134, + 940.113169, + 966.314136, + 992.297636, + 1018.060311, + 1043.598837, ]) vy = np.array([ 2590.964968, - 2517.380329, - 2443.474728, - 2369.256838, - 2294.735374, - 2219.919093, - 2144.816789, - 2069.437298, + 2517.380329, + 2443.474728, + 2369.256838, + 2294.735374, + 2219.919093, + 2144.816789, + 2069.437298, ]) vz = np.array([ - -7090.378144, - -7113.598127, - -7136.014344, - -7157.624244, - -7178.425371, - -7198.415359, - -7217.591940, - -7235.952940, + -7090.378144, + -7113.598127, + -7136.014344, + -7157.624244, + -7178.425371, + -7198.415359, + -7217.591940, + -7235.952940, ]) return [tr, x, y, z, vx, vy, vz], ref_time @@ -97,101 +97,119 @@ def svs(): def test_read_ESA_Orbit_file(svs): true_svs, ref_time = svs filename = os.path.join(SCENARIO_DIR, 'S1_orbit_example.EOF') - svs = read_ESA_Orbit_file(filename, ref_time) + svs = read_ESA_Orbit_file(filename, ref_time) assert [np.allclose(s, ts) for s, ts in zip(svs, true_svs)] + def test_read_txt_file(svs): true_svs, ref_time = svs filename = os.path.join(SCENARIO_DIR, 'S1_sv_file.txt') - svs = read_txt_file(filename) + svs = read_txt_file(filename) assert [np.allclose(s, ts) for s, ts in zip(svs, true_svs)] + def test_get_sv_1(svs): true_svs, ref_time = svs filename = os.path.join(SCENARIO_DIR, 'S1_orbit_example.EOF') svs = get_sv(filename, ref_time) assert [np.allclose(s, ts) for s, ts in zip(svs, true_svs)] - + + def test_get_sv_2(svs): true_svs, ref_time = svs filename = os.path.join(SCENARIO_DIR, 'S1_sv_file.txt') svs = get_sv(filename, ref_time) assert [np.allclose(s, ts) for s, ts in zip(svs, true_svs)] - + + def test_get_sv_3(svs): true_svs, ref_time = svs filename = os.path.join(SCENARIO_DIR, 'dummy.txt') with pytest.raises(ValueError): get_sv(filename, ref_time) - + + def test_get_sv_4(svs): true_svs, ref_time = svs filename = os.path.join(SCENARIO_DIR, 'no_exist.txt') with pytest.raises(FileNotFoundError): get_sv(filename, ref_time) - + + def test_cut_times(svs): true_svs, ref_time = svs assert len(true_svs[0][cut_times(true_svs[0])]) == len(true_svs[0]) + def test_cut_times_2(svs): true_svs, ref_time = svs assert len(true_svs[0][cut_times(true_svs[0], pad=5)]) == 1 + def test_cut_times_3(svs): true_svs, ref_time = svs assert len(true_svs[0][cut_times(true_svs[0], pad=15)]) == 3 + def test_cut_times_4(svs): true_svs, ref_time = svs - + assert len(true_svs[0][cut_times(true_svs[0], pad=400)]) == len(true_svs[0]) + def test_los_to_lv(): with pytest.raises(ValueError): inc_hd_to_enu(-10, 0) + def test_los_to_lv_2(): assert np.allclose( - inc_hd_to_enu(0, 0), - np.array([0, 0, 1]) - ) + inc_hd_to_enu(0, 0), + np.array([0, 0, 1]) + ) + def test_los_to_lv_3(): assert np.allclose( - inc_hd_to_enu(0, -180), - np.array([0, 0, 1]) - ) + inc_hd_to_enu(0, -180), + np.array([0, 0, 1]) + ) + def test_los_to_lv_3b(): assert np.allclose( - inc_hd_to_enu(0, 18), - np.array([0, 0, 1]) - ) + inc_hd_to_enu(0, 18), + np.array([0, 0, 1]) + ) + def test_los_to_lv_3c(): assert np.allclose( - inc_hd_to_enu(0, -18), - np.array([0, 0, 1]) - ) + inc_hd_to_enu(0, -18), + np.array([0, 0, 1]) + ) + def test_los_to_lv_4(): assert np.allclose( - inc_hd_to_enu(35, 0), + inc_hd_to_enu(35, 0), np.array([0, np.sin(np.radians(35)), np.cos(np.radians(35))]) - ) - + ) + + def test_los_to_lv_5(): assert np.allclose( - inc_hd_to_enu(35, 180), + inc_hd_to_enu(35, 180), np.array([0, -np.sin(np.radians(35)), np.cos(np.radians(35))]) - ) + ) + def test_los_to_lv_6(): assert np.allclose( - inc_hd_to_enu(35, 90), + inc_hd_to_enu(35, 90), np.array([-np.sin(np.radians(35)), 0, np.cos(np.radians(35))]) - ) + ) + def test_zenith_1(): assert np.allclose( @@ -199,33 +217,37 @@ def test_zenith_1(): np.array([1, 0, 0]) ) + def test_zenith_2(): assert np.allclose( getZenithLookVecs(np.array([90]), np.array([0]), np.array([0])), np.array([0, 0, 1]) ) + def test_zenith_3(): assert np.allclose( getZenithLookVecs(np.array([-90]), np.array([0]), np.array([0])), np.array([0, 0, -1]) ) + def test_zenith_4(): assert np.allclose( getZenithLookVecs(np.array([0]), np.array([180]), np.array([0])), np.array([-1, 0, 0]) ) + def test_zenith_5(): assert np.allclose( getZenithLookVecs(np.array([0]), np.array([90]), np.array([0])), np.array([0, 1, 0]) ) + def test_zenith_6(): assert np.allclose( getZenithLookVecs(np.array([0]), np.array([0]), np.array([1000])), np.array([1, 0, 0]) ) - diff --git a/test/test_scenario_1.py b/test/test_scenario_1.py index 6fece56bd..eed6aa56c 100755 --- a/test/test_scenario_1.py +++ b/test/test_scenario_1.py @@ -140,5 +140,5 @@ def core_test_tropo_delay(tmp_path, modelName): ) # get the true delay from the weather model - assert np.nanmax(np.abs((wet - true_wet) / true_wet )) < _RTOL - assert np.nanmax(np.abs((hydro - true_hydro) / true_hydro )) < _RTOL + assert np.nanmax(np.abs((wet - true_wet) / true_wet)) < _RTOL + assert np.nanmax(np.abs((hydro - true_hydro) / true_hydro)) < _RTOL diff --git a/test/test_scenario_2.py b/test/test_scenario_2.py index 1e0cde7e7..dc7bfe1e0 100644 --- a/test/test_scenario_2.py +++ b/test/test_scenario_2.py @@ -67,6 +67,5 @@ def test_computeDelay(tmp_path): true_delay = pd.read_csv(true_delay) # get the true delay from the weather model - assert np.sum((est_delay['wetDelay'].values - true_delay['wetDelay'].values) / true_delay['wetDelay'].values) < _RTOL + assert np.sum((est_delay['wetDelay'].values - true_delay['wetDelay'].values) / true_delay['wetDelay'].values) < _RTOL assert np.sum((est_delay['hydroDelay'].values - true_delay['hydroDelay'].values) / true_delay['hydroDelay'].values) < _RTOL - diff --git a/test/test_util.py b/test/test_util.py index 31264db60..12f5b4e90 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -337,12 +337,12 @@ def test_WGS84_to_UTM(): @pytest.mark.skipif(True, reason='Need to ensure this file always get written before this executes') def test_read_weather_model_file(): weather_model_obj = read_wm_file( - os.path.join( - SCENARIO_DIR, - 'weather_files', - 'ERA5_2020_01_03_T23_00_00_15.75N_18.25N_103.24W_99.75W.nc' - ) + os.path.join( + SCENARIO_DIR, + 'weather_files', + 'ERA5_2020_01_03_T23_00_00_15.75N_18.25N_103.24W_99.75W.nc' ) + ) assert weather_model_obj.Model() == 'ERA-5' @@ -352,30 +352,35 @@ def test_enu2ecef_1(): ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) assert np.allclose(ecef, np.array([1, 0, 0])) + def test_enu2ecef_2(): enu = np.array([0, 0, 1]) llh = np.array([0, 90, 0]) ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) assert np.allclose(ecef, np.array([0, 1, 0])) + def test_enu2ecef_3(): enu = np.array([0, 0, 1]) llh = np.array([0, -90, 0]) ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) assert np.allclose(ecef, np.array([0, -1, 0])) + def test_enu2ecef_4(): enu = np.array([0, 0, 1]) llh = np.array([90, 0, 0]) ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) assert np.allclose(ecef, np.array([0, 0, 1])) + def test_enu2ecef_5(): enu = np.array([0, 0, 1]) llh = np.array([-90, 0, 0]) ecef = enu2ecef(enu[0], enu[1], enu[2], llh[0], llh[1], llh[2]) assert np.allclose(ecef, np.array([0, 0, -1])) + def test_enu2ecef_6(): enu = np.array([0, 1, 0]) llh = np.array([0, 0, 0]) @@ -389,51 +394,58 @@ def test_ecef2enu_1(): enu = ecef2enu(enu, llh[0], llh[1], llh[2]) assert np.allclose(enu, np.array([0, 1, 0])) + def test_ecef2enu_2(): enu = np.array([0, 0, 1]) llh = np.array([0, 90, 0]) ecef = ecef2enu(enu, llh[0], llh[1], llh[2]) assert np.allclose(ecef, np.array([0, 1, 0])) + def test_ecef2enu_3(): enu = np.array([0, 0, 1]) llh = np.array([0, -90, 0]) ecef = ecef2enu(enu, llh[0], llh[1], llh[2]) assert np.allclose(ecef, np.array([0, 1, 0])) + def test_ecef2enu_4(): enu = np.array([0, 0, 1]) llh = np.array([90, 0, 0]) ecef = ecef2enu(enu, llh[0], llh[1], llh[2]) assert np.allclose(ecef, np.array([0, 0, 1])) + def test_ecef2enu_5(): enu = np.array([0, 0, 1]) llh = np.array([-90, 0, 0]) ecef = ecef2enu(enu, llh[0], llh[1], llh[2]) assert np.allclose(ecef, np.array([0, 0, -1])) + def test_ecef2enu_6(): enu = np.array([0, 0, -1]) llh = np.array([0, -180, 0]) ecef = ecef2enu(enu, llh[0], llh[1], llh[2]) assert np.allclose(ecef, np.array([0, -1, 0])) + def test_ecef2enu_7(): enu = np.array([0, 0, 1]) llh = np.array([0, -180, 1000]) ecef = ecef2enu(enu, llh[0], llh[1], llh[2]) assert np.allclose(ecef, np.array([0, 1, 0])) + def test_ecef2enu_8(): enu = np.array([1, 1, 0]) llh = np.array([0, 0, 0]) ecef = ecef2enu(enu, llh[0], llh[1], llh[2]) assert np.allclose(ecef, np.array([1, 0, 1])) + def test_ecef2enu_9(): enu = np.array([1, 1, 0]) llh = np.array([0, 180, 0]) ecef = ecef2enu(enu, llh[0], llh[1], llh[2]) assert np.allclose(ecef, np.array([-1, 0, -1])) - diff --git a/test/weather_model/test_weather_model.py b/test/weather_model/test_weather_model.py index cc1ceca34..702f117aa 100644 --- a/test/weather_model/test_weather_model.py +++ b/test/weather_model/test_weather_model.py @@ -151,7 +151,7 @@ def test_uniform_in_z_small(model): model._p = np.arange(8).reshape(2, 2, 2) model._t = model._p * 2 model._e = model._p * 3 - model._lats = model._zs # for now just passing in dummy arrays for lats, lons + model._lats = model._zs # for now just passing in dummy arrays for lats, lons model._lons = model._zs model._uniform_in_z() @@ -188,7 +188,7 @@ def test_uniform_in_z_large(model): model._p = np.tile(np.arange(y).reshape(-1, 1) * np.ones(z), (x, 1, 1)) model._t = model._p * 2 model._e = model._p * 3 - model._lats = model._zs # for now just passing in dummy arrays for lats, lons + model._lats = model._zs # for now just passing in dummy arrays for lats, lons model._lons = model._zs assert model._p.shape == shape diff --git a/tools/RAiDER/checkArgs.py b/tools/RAiDER/checkArgs.py index 41e76ca48..44b0333c7 100644 --- a/tools/RAiDER/checkArgs.py +++ b/tools/RAiDER/checkArgs.py @@ -222,5 +222,3 @@ def modelName2Module(model_name): model_module = importlib.import_module(module_name) wmObject = getattr(model_module, model_name.upper().replace('-', '')) return module_name, wmObject - - diff --git a/tools/RAiDER/constants.py b/tools/RAiDER/constants.py index 89260d036..86d504db5 100644 --- a/tools/RAiDER/constants.py +++ b/tools/RAiDER/constants.py @@ -18,6 +18,7 @@ R_EARTH_MAX = 6378137 R_EARTH_MIN = 6356752 + class Zenith: """Special value indicating a look vector of "zenith".""" pass diff --git a/tools/RAiDER/delay.py b/tools/RAiDER/delay.py index e1e1530fd..d93cc0956 100755 --- a/tools/RAiDER/delay.py +++ b/tools/RAiDER/delay.py @@ -62,7 +62,6 @@ def computeDelay( step ) - wet, hydro = RAiDER.delayFcns.get_delays( step, pnts_file_name, @@ -171,7 +170,7 @@ def tropo_delay(args): logger.debug('Beginning line-of-sight calculation') # Convert the line-of-sight inputs to look vectors - los,lengths = getLookVectors(los, lats, lons, hgts, zref = zref, time = time) + los, lengths = getLookVectors(los, lats, lons, hgts, zref=zref, time=time) # write to an HDF5 file writePnts2HDF5(lats, lons, hgts, los, lengths, outName=pnts_file) diff --git a/tools/RAiDER/gnss/processDelayFiles.py b/tools/RAiDER/gnss/processDelayFiles.py index d07fd5cc1..2e5f43f21 100644 --- a/tools/RAiDER/gnss/processDelayFiles.py +++ b/tools/RAiDER/gnss/processDelayFiles.py @@ -1,3 +1,5 @@ +from textwrap import dedent +import numpy as np import argparse import datetime import glob @@ -9,9 +11,6 @@ import pandas as pd pd.options.mode.chained_assignment = None # default='warn' -import numpy as np - -from textwrap import dedent def combineDelayFiles(outName, loc=os.getcwd(), source='model', ext='.csv', ref=None, col_name='ZTD'): @@ -92,9 +91,10 @@ def getDateTime(filename): dtr = re.compile(r'\d{8}T\d{6}') dt = dtr.search(filename) return datetime.datetime.strptime( - dt.group(), - '%Y%m%dT%H%M%S' - ) + dt.group(), + '%Y%m%dT%H%M%S' + ) + def update_time(row, localTime_hrs): '''Update with local origin time''' @@ -103,19 +103,21 @@ def update_time(row, localTime_hrs): time_shift = datetime.timedelta(days=0) # if lon <0, check if you need to add day if row['Lon'] < 0: - #round to nearest hour + # round to nearest hour days_diff = (row['Datetime'] - \ - datetime.timedelta(seconds=math.floor(row['Localtime'])*3600)).day - \ - localTime_estimate.day + datetime.timedelta(seconds=math.floor(row['Localtime']) * 3600)).day - \ + localTime_estimate.day # add day if days_diff != 0: time_shift = datetime.timedelta(days=1) - return localTime_estimate + datetime.timedelta(seconds=row['Localtime']*3600) + time_shift + return localTime_estimate + datetime.timedelta(seconds=row['Localtime'] * 3600) + time_shift + def pass_common_obs(reference, target): '''Pass only observations in target spatiotemporally common to reference''' return target[target['Datetime'].dt.date.isin(reference['Datetime'].dt.date) & target['ID'].isin(reference['ID'])] + def concatDelayFiles( fileList, sort_list=['ID', 'Datetime'], @@ -153,8 +155,8 @@ def concatDelayFiles( print('Total number of rows in the concatenated file: {}'.format(df_c.shape[0])) print('Total number of rows containing NaNs: {}'.format( - df_c[df_c.isna().any(axis=1)].shape[0] - ) + df_c[df_c.isna().any(axis=1)].shape[0] + ) ) if return_df or outName is None: @@ -173,35 +175,35 @@ def local_time_filter(raiderFile, ztdFile, dfr, dfz, localTime): ''' localTime_hrs = int(localTime.split(' ')[0]) localTime_hrthreshold = int(localTime.split(' ')[1]) - #with rotation rate and distance to 0 lon, get localtime shift WRT 00 UTC at 0 lon - #*rotation rate at given point = (360deg/23.9333333333hr) = 15.041782729825965 deg/hr + # with rotation rate and distance to 0 lon, get localtime shift WRT 00 UTC at 0 lon + # *rotation rate at given point = (360deg/23.9333333333hr) = 15.041782729825965 deg/hr dfr['Localtime'] = (dfr['Lon'] / 15.041782729825965) dfz['Localtime'] = (dfz['Lon'] / 15.041782729825965) - #estimate local-times + # estimate local-times dfr['Localtime'] = dfr.apply(lambda r: update_time(r, localTime_hrs), axis=1) dfz['Localtime'] = dfz.apply(lambda r: update_time(r, localTime_hrs), axis=1) - #filter out data outside of --localtime hour threshold + # filter out data outside of --localtime hour threshold dfr['Localtime_u'] = dfr['Localtime'] + datetime.timedelta(hours=localTime_hrthreshold) dfr['Localtime_l'] = dfr['Localtime'] - datetime.timedelta(hours=localTime_hrthreshold) OG_total = dfr.shape[0] dfr = dfr[(dfr['Datetime'] >= dfr['Localtime_l']) & (dfr['Datetime'] <= dfr['Localtime_u'])] print('Total number of datapoints dropped in {} for not being within {} hrs of specified local-time {}: {} out of {}'.format( - raiderFile, localTime.split(' ')[1], localTime.split(' ')[0], dfr.shape[0], OG_total)) + raiderFile, localTime.split(' ')[1], localTime.split(' ')[0], dfr.shape[0], OG_total)) dfz['Localtime_u'] = dfz['Localtime'] + datetime.timedelta(hours=localTime_hrthreshold) dfz['Localtime_l'] = dfz['Localtime'] - datetime.timedelta(hours=localTime_hrthreshold) OG_total = dfz.shape[0] dfz = dfz[(dfz['Datetime'] >= dfz['Localtime_l']) & (dfz['Datetime'] <= dfz['Localtime_u'])] print('Total number of datapoints dropped in {} for not being within {} hrs of specified local-time {}: {} out of {}'.format( - ztdFile, localTime.split(' ')[1], localTime.split(' ')[0], dfz.shape[0], OG_total)) + ztdFile, localTime.split(' ')[1], localTime.split(' ')[0], dfz.shape[0], OG_total)) # drop all lines with nans dfr.dropna(how='any', inplace=True) dfz.dropna(how='any', inplace=True) # drop all duplicate lines dfr.drop_duplicates(inplace=True) dfz.drop_duplicates(inplace=True) - #drop and rename columns + # drop and rename columns dfr.drop(columns=['Localtime_l', 'Localtime_u', 'Datetime'], inplace=True) dfr.rename(columns={'Localtime': 'Datetime'}, inplace=True) dfz.drop(columns=['Localtime_l', 'Localtime_u', 'Datetime'], inplace=True) @@ -211,13 +213,13 @@ def local_time_filter(raiderFile, ztdFile, dfr, dfz, localTime): def mergeDelayFiles( - raiderFile, - ztdFile, - col_name='ZTD', - raider_delay='totalDelay', - outName=None, - localTime=None - ): + raiderFile, + ztdFile, + col_name='ZTD', + raider_delay='totalDelay', + outName=None, + localTime=None +): ''' Merge a combined RAiDER delays file with a GPS ZTD delay file ''' @@ -235,18 +237,18 @@ def mergeDelayFiles( print('Beginning merge') dfc = dfr.merge( - dfz[['ID', 'Datetime', 'ZTD', 'sigZTD']], - how='left', - left_on=['Datetime', 'ID'], - right_on=['Datetime', 'ID'], - sort=True - ) + dfz[['ID', 'Datetime', 'ZTD', 'sigZTD']], + how='left', + left_on=['Datetime', 'ID'], + right_on=['Datetime', 'ID'], + sort=True + ) dfc['ZTD_minus_RAiDER'] = dfc['ZTD'] - dfc[raider_delay] print('Total number of rows in the concatenated file: {}'.format(dfc.shape[0])) print('Total number of rows containing NaNs: {}'.format( - dfc[dfc.isna().any(axis=1)].shape[0] - ) + dfc[dfc.isna().any(axis=1)].shape[0] + ) ) print('Merge finished') @@ -386,8 +388,8 @@ def parseCMD(): combineDelayFiles(args.raider_file, loc=args.raider_folder) if ~os.path.exists(args.gnss_file): - combineDelayFiles(args.gnss_file, loc=args.gnss_folder, source = 'GNSS', - ref = args.raider_file, col_name=args.column_name) + combineDelayFiles(args.gnss_file, loc=args.gnss_folder, source='GNSS', + ref=args.raider_file, col_name=args.column_name) if args.gnss_file is not None: mergeDelayFiles( diff --git a/tools/RAiDER/losreader.py b/tools/RAiDER/losreader.py index 3c8b769ed..af2712008 100644 --- a/tools/RAiDER/losreader.py +++ b/tools/RAiDER/losreader.py @@ -26,7 +26,7 @@ _SLANT_RANGE_THRESH = 5e6 -def getLookVectors(los_type, lats, lons, heights, zref=_ZREF, time=None, pad=3*3600): +def getLookVectors(los_type, lats, lons, heights, zref=_ZREF, time=None, pad=3 * 3600): ''' Get unit look vectors pointing from the ground (target) pixels to the sensor, or to Zenith. Can be accomplished using an ISCE-style 2-band LOS file or a @@ -83,28 +83,28 @@ def getLookVectors(los_type, lats, lons, heights, zref=_ZREF, time=None, pad=3* LOS_enu = inc_hd_to_enu(*utilFcns.gdal_open(los_type)) lengths = (zref - heights) / utilFcns.cosd(utilFcns.gdal_open(los_type)[0]) look_vecs = utilFcns.enu2ecef( - LOS_enu[...,0], - LOS_enu[...,1], - LOS_enu[...,2], - lats, - lons, - heights - ) + LOS_enu[..., 0], + LOS_enu[..., 1], + LOS_enu[..., 2], + lats, + lons, + heights + ) # if that doesn't work, try parsing as a statevector (orbit) file except OSError: svs = np.stack(get_sv(los_type, time, pad), axis=-1) xyz_targets = np.stack(utilFcns.lla2ecef(lats, lons, heights), axis=-1) look_vecs = state_to_los( - svs, + svs, xyz_targets, ) enu = utilFcns.ecef2enu( look_vecs, - lats, - lons, + lats, + lons, heights) - lengths = (zref - heights) / enu[...,2] + lengths = (zref - heights) / enu[..., 2] # Otherwise, throw an error except: @@ -138,7 +138,7 @@ def getZenithLookVecs(lats, lons, heights): return np.stack([x, y, z], axis=-1) -def get_sv(los_file, ref_time, pad=3*3600): +def get_sv(los_file, ref_time, pad=3 * 3600): """ Read an LOS file and return orbital state vectors @@ -202,7 +202,7 @@ def inc_hd_to_enu(incidence, heading): return np.stack((east, north, up), axis=-1) -#@jit(nopython=True) +# @jit(nopython=True) def state_to_los(svs, xyz_targets): ''' Converts information from a state vector for a satellite orbit, given in terms of @@ -232,7 +232,7 @@ def state_to_los(svs, xyz_targets): ''' # check the inputs - if np.min(svs.shape)< 4: + if np.min(svs.shape) < 4: raise RuntimeError( 'state_to_los: At least 4 state vectors are required' ' for orbit interpolation' @@ -240,7 +240,7 @@ def state_to_los(svs, xyz_targets): # Flatten the input array for convenience in_shape = xyz_targets.shape - target_xyz = np.stack([xyz_targets[...,0].flatten(), xyz_targets[...,1].flatten(), xyz_targets[...,2].flatten()], axis=-1) + target_xyz = np.stack([xyz_targets[..., 0].flatten(), xyz_targets[..., 1].flatten(), xyz_targets[..., 2].flatten()], axis=-1) Npts = len(target_xyz) # Iterate through targets and compute LOS @@ -248,7 +248,7 @@ def state_to_los(svs, xyz_targets): los = np.empty((Npts, 3), dtype=np.float64) breakpoint() for k in range(Npts): - los[k,:], sr = get_radar_coordinate(target_xyz[k,:], svs) + los[k, :], sr = get_radar_coordinate(target_xyz[k, :], svs) slant_range.append(sr) slant_ranges = np.array(slant_range) @@ -269,7 +269,7 @@ def state_to_los(svs, xyz_targets): return los_ecef -def cut_times(times, pad=3600*3): +def cut_times(times, pad=3600 * 3): """ Slice the orbit file around the reference aquisition time. This is done by default using a three-hour window, which for Sentinel-1 empirically @@ -289,13 +289,13 @@ def cut_times(times, pad=3600*3): def read_shelve(filename): - #TODO: docstring and unit tests + # TODO: docstring and unit tests with shelve.open(filename, 'r') as db: obj = db['frame'] numSV = len(obj.orbit.stateVectors) breakpoint() - if numSV==0: + if numSV == 0: raise ValueError('read_shelve: the file has not statevectors') t = np.ones(numSV) @@ -414,7 +414,7 @@ def read_ESA_Orbit_file(filename, ref_time): return [t, x, y, z, vx, vy, vz] -#@jit(nopython=True) +# @jit(nopython=True) def get_radar_coordinate(xyz, svs, t0=None): ''' Calculate the coordinate of the sensor in ECEF at the time corresponding to ***. @@ -431,7 +431,7 @@ def get_radar_coordinate(xyz, svs, t0=None): ''' # initialize search if t0 is None: - t = (svs[:,0].max() - svs[:,0].min()) / 2 + t = (svs[:, 0].max() - svs[:, 0].min()) / 2 else: t = t0 @@ -441,17 +441,17 @@ def get_radar_coordinate(xyz, svs, t0=None): dts = [] for k in range(num_iteration): - x = interpolate(svs[:,0], svs[:,1], t) - y = interpolate(svs[:,0], svs[:,2], t) - z = interpolate(svs[:,0], svs[:,3], t) - vx = interpolate(svs[:,0], svs[:,4], t) - vy = interpolate(svs[:,0], svs[:,5], t) - vz = interpolate(svs[:,0], svs[:,6], t) - E1 = vx*(xyz[0] - x) + vy*(xyz[1] - y) + vz*(xyz[2] - z) - dE1 = vx*vx + vy*vy + vz*vz - dt = E1/dE1; + x = interpolate(svs[:, 0], svs[:, 1], t) + y = interpolate(svs[:, 0], svs[:, 2], t) + z = interpolate(svs[:, 0], svs[:, 3], t) + vx = interpolate(svs[:, 0], svs[:, 4], t) + vy = interpolate(svs[:, 0], svs[:, 5], t) + vz = interpolate(svs[:, 0], svs[:, 6], t) + E1 = vx * (xyz[0] - x) + vy * (xyz[1] - y) + vz * (xyz[2] - z) + dE1 = vx * vx + vy * vy + vz * vz + dt = E1 / dE1 dts.append(dt) - t = t+dt; + t = t + dt if np.abs(dt) < residual_threshold: break @@ -461,7 +461,7 @@ def get_radar_coordinate(xyz, svs, t0=None): slant_range = np.sqrt( np.square(los_x) + np.square(los_y) + np.square(los_z) - ); + ) breakpoint() return np.array([los_x, los_y, los_z]) / slant_range, slant_range @@ -474,7 +474,7 @@ def interpolate(t, var, tq): ---------- statevectors: ndarray - an Nt x 7 matrix of statevectors: [t x y z vx vy vz] tref: double - reference time requested (must be in the scope of t) - + Returns ------- x, y, z: double - sensor position in ECEF @@ -482,4 +482,3 @@ def interpolate(t, var, tq): ''' f = interp1d(t, var) return f(tq) - diff --git a/tools/RAiDER/models/ecmwf.py b/tools/RAiDER/models/ecmwf.py index cea33db35..1dac9c1e0 100755 --- a/tools/RAiDER/models/ecmwf.py +++ b/tools/RAiDER/models/ecmwf.py @@ -35,9 +35,8 @@ def __init__(self): self._lat_res = 0.2 self._proj = CRS.from_epsg(4326) - self._model_level_type = 'ml' # Default + self._model_level_type = 'ml' # Default - def setLevelType(self, levelType): '''Set the level type to model levels or pressure levels''' if levelType in ['ml', 'pl']: @@ -50,7 +49,6 @@ def setLevelType(self, levelType): else: self.__pressure_levels__() - @abstractmethod def __pressure_levels__(self): pass @@ -59,7 +57,7 @@ def __model_levels__(self): self._levels = 137 self._zlevels = np.flipud(LEVELS_137_HEIGHTS) self._a = A_137_HRES - self._b = B_137_HRES + self._b = B_137_HRES def load_weather(self, *args, **kwargs): ''' @@ -195,14 +193,14 @@ def _get_from_ecmwf(self, lat_min, lat_max, lat_step, lon_min, lon_max, }) def _get_from_cds( - self, - lat_min, - lat_max, - lat_step, - lon_min, + self, + lat_min, + lat_max, + lat_step, + lon_min, lon_max, - lon_step, - acqTime, + lon_step, + acqTime, outname ): import cdsapi @@ -212,7 +210,7 @@ def _get_from_cds( var = ['z', 'q', 't'] levType = 'pressure_level' else: - var = "129/130/133/152" #'lnsp', 'q', 'z', 't' + var = "129/130/133/152" # 'lnsp', 'q', 'z', 't' levType = 'model_level' bbox = [lat_max, lon_min, lat_min, lon_max] @@ -242,7 +240,6 @@ def _get_from_cds( logger.exception(e) raise Exception - def _download_ecmwf(self, lat_min, lat_max, lat_step, lon_min, lon_max, lon_step, time, out): from ecmwfapi import ECMWFService @@ -276,7 +273,6 @@ def _download_ecmwf(self, lat_min, lat_max, lat_step, lon_min, lon_max, lon_step out ) - def _load_pressure_level(self, filename, *args, **kwargs): with xr.open_dataset(filename) as block: # Pull the data @@ -349,7 +345,6 @@ def _load_pressure_level(self, filename, *args, **kwargs): self._t = np.flip(self._t, axis=2) self._q = np.flip(self._q, axis=2) - def _makeDataCubes(self, fname, verbose=False): ''' Create a cube of data representing temperature and relative humidity @@ -382,5 +377,3 @@ def _makeDataCubes(self, fname, verbose=False): 'you may have a problem with your mask') return lats, lons, xs, ys, t, q, lnsp, z - - diff --git a/tools/RAiDER/models/era5.py b/tools/RAiDER/models/era5.py index c6b0cacc6..45facaf07 100755 --- a/tools/RAiDER/models/era5.py +++ b/tools/RAiDER/models/era5.py @@ -8,7 +8,6 @@ from RAiDER.models.model_levels import A_137_ERA5, B_137_ERA5, LEVELS_137_HEIGHTS, LEVELS_25_HEIGHTS - class ERA5(ECMWF): # I took this from # https://www.ecmwf.int/en/forecasts/documentation-and-support/137-model-levels. @@ -27,7 +26,7 @@ def __init__(self): # Availability lag time in days self._lag_time = datetime.timedelta(days=30) - # Default, need to change to ml + # Default, need to change to ml self.setLevelType('pl') def __pressure_levels__(self): @@ -59,4 +58,3 @@ def load_weather(self, *args, **kwargs): raise RuntimeError( '{} is not a valid model type'.format(self._model_level_type) ) - diff --git a/tools/RAiDER/models/hres.py b/tools/RAiDER/models/hres.py index efda9808f..b8d73b9a6 100755 --- a/tools/RAiDER/models/hres.py +++ b/tools/RAiDER/models/hres.py @@ -34,10 +34,10 @@ def __init__(self, level_type='ml'): self._k3 = 3.75e3 # [K^2/Pa] # 9 km horizontal grid spacing. This is only used for extending the download-buffer, i.e. not in subsequent processing. - self._lon_res = 9./111 #0.08108115 - self._lat_res = 9./111 #0.08108115 - self._x_res = 9./111 #0.08108115 - self._y_res = 9./111 #0.08108115 + self._lon_res = 9. / 111 # 0.08108115 + self._lat_res = 9. / 111 # 0.08108115 + self._x_res = 9. / 111 # 0.08108115 + self._y_res = 9. / 111 # 0.08108115 self._humidityType = 'q' # Default, pressure levels are 'pl' @@ -54,20 +54,18 @@ def __init__(self, level_type='ml'): self.setLevelType('ml') - def __pressure_levels__(self): self._levels = 25 self._zlevels = np.flipud(LEVELS_25_HEIGHTS) def update_a_b(self): - # Before 2013-06-26, there were only 91 model levels. The mapping coefficients below are extracted + # Before 2013-06-26, there were only 91 model levels. The mapping coefficients below are extracted # based on https://www.ecmwf.int/en/forecasts/documentation-and-support/91-model-levels self._levels = 91 self._zlevels = np.flipud(LEVELS_91_HEIGHTS) self._a = A_91_HRES self._b = B_91_HRES - def load_weather(self, filename=None): ''' Consistent class method to be implemented across all weather model types. @@ -84,7 +82,6 @@ def load_weather(self, filename=None): self._load_model_levels(filename) elif self._model_level_type == 'pl': self._load_pressure_levels(filename) - def _fetch(self, lats, lons, time, out, Nextra=2): ''' @@ -98,5 +95,3 @@ def _fetch(self, lats, lons, time, out, Nextra=2): # execute the search at ECMWF self._download_ecmwf(lat_min, lat_max, self._lat_res, lon_min, lon_max, self._lon_res, time, out) - - diff --git a/tools/RAiDER/models/model_levels.py b/tools/RAiDER/models/model_levels.py index 369d49c28..ba78f9f4a 100644 --- a/tools/RAiDER/models/model_levels.py +++ b/tools/RAiDER/models/model_levels.py @@ -505,5 +505,3 @@ -300, -500, ] - - diff --git a/tools/RAiDER/models/ncmr.py b/tools/RAiDER/models/ncmr.py index 020054dbd..e82250491 100755 --- a/tools/RAiDER/models/ncmr.py +++ b/tools/RAiDER/models/ncmr.py @@ -13,9 +13,9 @@ from RAiDER.models.weatherModel import WeatherModel from RAiDER.logger import logger from RAiDER.utilFcns import ( - writeWeatherVars2NETCDF4, - roundTime, - read_NCMR_loginInfo, + writeWeatherVars2NETCDF4, + roundTime, + read_NCMR_loginInfo, show_progress ) @@ -90,27 +90,25 @@ def _download_ncmr_file(self, out, date_time, bounding_box): Download weather model data (whole globe) from NCMR weblink, crop it to the region of interest, and save the cropped data as a standard .nc file of RAiDER (e.g. "NCMR_YYYY_MM_DD_THH_MM_SS.nc"); Temporarily download data from NCMR ftp 'https://ftp.ncmrwf.gov.in/pub/outgoing/SAC/NCUM_OSF/' and copied in weather_models folder ''' - + from netCDF4 import Dataset - + ############# Use these lines and modify the link when actually downloading NCMR data from a weblink ############# - url, username, password = read_NCMR_loginInfo(); + url, username, password = read_NCMR_loginInfo() filename = os.path.basename(out) url = f'ftp://{username}:{password}@{url}/TEST/{filename}' filepath = f'{out[:-3]}_raw.nc' if not os.path.exists(filepath): logger.info('Fetching URL: %s', url) - local_filename, headers = urllib.request.urlretrieve(url,filepath,show_progress) + local_filename, headers = urllib.request.urlretrieve(url, filepath, show_progress) else: logger.warning('Weather model already exists, skipping download') ######################################################################################################################## - ############# For debugging: use pre-downloaded files; Remove/comment out it when actually downloading NCMR data from a weblink ############# # filepath = os.path.dirname(out) + '/NCUM_ana_mdllev_20180701_00z.nc' ######################################################################################################################## - # calculate the array indices for slicing the GMAO variable arrays lat_min_ind = int((self._bounds[0] - (-89.94141)) / self._lat_res) lat_max_ind = int((self._bounds[1] - (-89.94141)) / self._lat_res) @@ -125,7 +123,7 @@ def _download_ncmr_file(self, out, date_time, bounding_box): ml_min = 0 ml_max = 70 - + with Dataset(filepath, 'r', maskandscale=True) as f: lats = f.variables['latitude'][lat_min_ind:(lat_max_ind + 1)].copy() if (self._bounds[2] * self._bounds[3] < 0): @@ -140,7 +138,7 @@ def _download_ncmr_file(self, out, date_time, bounding_box): t = np.append(t1, t2, axis=2) else: t = f.variables['air_temperature'][ml_min:(ml_max + 1), lat_min_ind:(lat_max_ind + 1), lon_min_ind:(lon_max_ind + 1)].copy() - + # Skipping first pressure levels (below 20 meter) if (self._bounds[2] * self._bounds[3] < 0): q1 = f.variables['specific_humidity'][(ml_min + 1):(ml_max + 1), lat_min_ind:(lat_max_ind + 1), lon_min_ind:].copy() @@ -154,7 +152,7 @@ def _download_ncmr_file(self, out, date_time, bounding_box): p = np.append(p1, p2, axis=2) else: p = f.variables['air_pressure'][(ml_min + 1):(ml_max + 1), lat_min_ind:(lat_max_ind + 1), lon_min_ind:(lon_max_ind + 1)].copy() - + level_hgt = f.variables['level_height'][(ml_min + 1):(ml_max + 1)].copy() if (self._bounds[2] * self._bounds[3] < 0): surface_alt1 = f.variables['surface_altitude'][lat_min_ind:(lat_max_ind + 1), lon_min_ind:].copy() @@ -162,14 +160,13 @@ def _download_ncmr_file(self, out, date_time, bounding_box): surface_alt = np.append(surface_alt1, surface_alt2, axis=1) else: surface_alt = f.variables['surface_altitude'][lat_min_ind:(lat_max_ind + 1), lon_min_ind:(lon_max_ind + 1)].copy() - + hgt = np.zeros([len(level_hgt), len(surface_alt[:, 1]), len(surface_alt[1, :])]) for i in range(len(level_hgt)): hgt[i, :, :] = surface_alt[:, :] + level_hgt[i] - + lons[lons > 180] -= 360 - ############# For debugging: comment it out when using pre-downloaded raw data files and don't want to remove them for test; Uncomment it when actually downloading NCMR data from a weblink ############# os.remove(filepath) ######################################################################################################################## @@ -179,13 +176,12 @@ def _download_ncmr_file(self, out, date_time, bounding_box): except Exception: logger.exception("Unable to save weathermodel to file") - def _makeDataCubes(self, filename): ''' Get the variables from the saved .nc file (named as "NCMR_YYYY_MM_DD_THH_MM_SS.nc") ''' from netCDF4 import Dataset - + # adding the import here should become absolute when transition to netcdf with Dataset(filename, mode='r') as f: lons = np.array(f.variables['x'][:]) diff --git a/tools/RAiDER/models/weatherModel.py b/tools/RAiDER/models/weatherModel.py index b422008a7..af9fa2b1c 100755 --- a/tools/RAiDER/models/weatherModel.py +++ b/tools/RAiDER/models/weatherModel.py @@ -54,7 +54,7 @@ def __init__(self): # Define fixed constants self._R_v = 461.524 - self._R_d = 287.06 # in our original code this was 287.053 + self._R_d = 287.06 # in our original code this was 287.053 self._g0 = _g0 # gravity constant self._zmin = _ZMIN # minimum integration height self._zmax = _ZREF # max integration height @@ -560,7 +560,7 @@ def _calculategeoh(self, z, lnsp): Ph_lev = self._a[lev - 1] + (self._b[lev - 1] * sp) Ph_levplusone = self._a[lev] + (self._b[lev] * sp) - pressurelvs[ilevel] = (Ph_lev + Ph_levplusone)/2 # average pressure at half-levels above and below + pressurelvs[ilevel] = (Ph_lev + Ph_levplusone) / 2 # average pressure at half-levels above and below if lev == 1: dlogP = np.log(Ph_levplusone / 0.1) @@ -583,7 +583,6 @@ def _calculategeoh(self, z, lnsp): # integrate z_h to next half level z_h += TRd * dlogP - return geopotential, pressurelvs, geoheight def _get_ll_bounds(self, lats=None, lons=None, Nextra=2): diff --git a/tools/RAiDER/processWM.py b/tools/RAiDER/processWM.py index 2f8a90cce..359769c6b 100755 --- a/tools/RAiDER/processWM.py +++ b/tools/RAiDER/processWM.py @@ -42,7 +42,7 @@ def prepareWeatherModel( if weather_model.files is None: if time is None: raise RuntimeError( - 'prepareWeatherModel: Either a file or a time must be specified' + 'prepareWeatherModel: Either a file or a time must be specified' ) weather_model.filename(time, wmLoc) if os.path.exists(weather_model.files[0]): diff --git a/tools/RAiDER/statsPlot.py b/tools/RAiDER/statsPlot.py index e257ec0ae..0a7f107f9 100755 --- a/tools/RAiDER/statsPlot.py +++ b/tools/RAiDER/statsPlot.py @@ -81,7 +81,7 @@ def create_parser(): dtsubsets.add_argument('-si', '--seasonalinterval', dest='seasonalinterval', type=str, default=None, help="Subset in by an specific interval for each year by specifying earliest MM-DD time followed by latest MM-DD time. -- Example : '03-21 06-21'.") dtsubsets.add_argument('-oe', '--obs_errlimit', dest='obs_errlimit', type=float, default='inf', - help="Observation error threshold to discard observations with large uncertainties.") + help="Observation error threshold to discard observations with large uncertainties.") # Plot formatting/options pltformat = parser.add_argument_group( @@ -175,11 +175,11 @@ def convert_SI(val, unit_in, unit_out): Convert input to desired units ''' - SI = {'mm': 0.001, 'cm': 0.01, 'm': 1.0, 'km': 1000., + SI = {'mm': 0.001, 'cm': 0.01, 'm': 1.0, 'km': 1000., 'mm^2': 1e-6, 'cm^2': 1e-4, 'm^2': 1.0, 'km^2': 1e+6} # avoid conversion if output unit in years - if unit_in in ['days','years']: + if unit_in in ['days', 'years']: return val # check if output spatial unit is supported @@ -526,7 +526,7 @@ def _append_variogram(self, grid_ind, grid_subset): self.TOT_good_slices.append([grid_ind, tot_timetag]) self.TOT_res_robust_arr.append(TOT_res_robust.x) self.TOT_tot_timetag.append(tot_timetag) - var_rmse = np.sqrt(np.nanmean((TOT_res_robust.fun)**2)) + var_rmse = np.sqrt(np.nanmean((TOT_res_robust.fun)**2)) if var_rmse <= self.variogram_errlimit: self.TOT_res_robust_rmse.append(var_rmse) else: @@ -1302,10 +1302,10 @@ def _amplitude_and_phase(self, station, tt, yy, min_span=2, min_frac=0.6, period # Fit with custom fit function with fixed period, if specified if period_limit != 0: # convert from years to radians/seconds - w = (1/period_limit) * (1/31556952) * (2.*np.pi) - custom_sine_function_base = lambda t, A, p, c: self._sine_function_base(t, A, w, p, c) + w = (1 / period_limit) * (1 / 31556952) * (2. * np.pi) + def custom_sine_function_base(t, A, p, c): return self._sine_function_base(t, A, w, p, c) else: - custom_sine_function_base = lambda t, A, w, p, c: self._sine_function_base(t, A, w, p, c) + def custom_sine_function_base(t, A, w, p, c): return self._sine_function_base(t, A, w, p, c) # If station TS does not span specified time period, pass NaNs time_span_yrs = (max(tt) - min(tt)) / 31556952 if time_span_yrs >= min_span and len(list(set(tt))) / (time_span_yrs * 365.25) >= min_frac: @@ -1316,7 +1316,7 @@ def _amplitude_and_phase(self, station, tt, yy, min_span=2, min_frac=0.6, period guess_freq = abs(ff[np.argmax(Fyy[1:]) + 1]) # excluding the zero period "peak", which is related to offset guess_amp = np.std(yy) * 2.**0.5 guess_offset = np.mean(yy) - guess = np.array([guess_amp, 2.*np.pi * guess_freq, 0., guess_offset]) + guess = np.array([guess_amp, 2. * np.pi * guess_freq, 0., guess_offset]) # Adjust frequency guess to reflect fixed period, if specified if period_limit != 0: guess = np.array([guess_amp, 0., guess_offset]) @@ -1335,7 +1335,7 @@ def _amplitude_and_phase(self, station, tt, yy, min_span=2, min_frac=0.6, period self.ampfit_c.append(np.nan), self.phsfit_c.append(np.nan), \ self.periodfit_c.append(np.nan), self.seasonalfit_rmse.append(np.nan) return self.ampfit, self.phsfit, self.periodfit, self.ampfit_c, \ - self.phsfit_c, self.periodfit_c, self.seasonalfit_rmse + self.phsfit_c, self.periodfit_c, self.seasonalfit_rmse except OptimizeWarning: optimize_warning = True warnings.simplefilter("ignore", OptimizeWarning) @@ -1359,7 +1359,7 @@ def fitfunc(t): return A * np.sin(w * t + p) + c # Convert phase from rad to days, apply half wavelength shift if Amp is negative if A < 0: p += 3.14159 - phsfit[station] = (365.25/2)*np.sin(p) + phsfit[station] = (365.25 / 2) * np.sin(p) periodfit[station] = f # Catch warning where output is so small that it gets rounded to 0 # I.e. RuntimeWarning: invalid value encountered in double_scalars @@ -1370,9 +1370,9 @@ def fitfunc(t): return A * np.sin(w * t + p) + c periodfit_c[station] = pcov[1, 1]**0.5 phsfit_c[station] = pcov[2, 2]**0.5 # pass RMSE of fit - seasonalfit_rmse[station] = yy - custom_sine_function_base(tt,*popt) - seasonalfit_rmse[station] = (scipy_sum(seasonalfit_rmse[station]**2)/ \ - (seasonalfit_rmse[station].size-2))**0.5 + seasonalfit_rmse[station] = yy - custom_sine_function_base(tt, *popt) + seasonalfit_rmse[station] = (scipy_sum(seasonalfit_rmse[station]**2) / \ + (seasonalfit_rmse[station].size - 2))**0.5 except FloatingPointError: pass if self.phaseamp_per_station or optimize_warning: @@ -1410,7 +1410,7 @@ def fitfunc(t): return A * np.sin(w * t + p) + c self.seasonalfit_rmse.append(seasonalfit_rmse) return self.ampfit, self.phsfit, self.periodfit, self.ampfit_c, \ - self.phsfit_c, self.periodfit_c, self.seasonalfit_rmse + self.phsfit_c, self.periodfit_c, self.seasonalfit_rmse def _sine_function_base(self, t, A, w, p, c): ''' @@ -1605,9 +1605,9 @@ def __call__(self, gridarr, plottype, workdir='./', drawgridlines=False, colorba axes.set_title(userTitle, zorder=2) # save/close figure - #cbar_ax.ax.locator_params(nbins=10) - #for label in cbar_ax.ax.xaxis.get_ticklabels()[::25]: - #label.set_visible(False) + # cbar_ax.ax.locator_params(nbins=10) + # for label in cbar_ax.ax.xaxis.get_ticklabels()[::25]: + # label.set_visible(False) plt.savefig(os.path.join(workdir, self.col_name + '_' + plottype + '.' + plotFormat), format=plotFormat, bbox_inches='tight') plt.close() @@ -1892,7 +1892,7 @@ def stats_analyses( # write sill gridfile_name = os.path.join(workdir, col_name + '_' + 'grid_variance' + '.tif') save_gridfile(df_stats.grid_variance, 'grid_variance', gridfile_name, df_stats.plotbbox, df_stats.spacing, \ - df_stats.unit+'^2', colorbarfmt='%.3e', stationsongrids=df_stats.stationsongrids, gdal_fmt='float32') + df_stats.unit + '^2', colorbarfmt='%.3e', stationsongrids=df_stats.stationsongrids, gdal_fmt='float32') # write variogram rmse gridfile_name = os.path.join(workdir, col_name + '_' + 'grid_variogram_rmse' + '.tif') save_gridfile(df_stats.grid_variogram_rmse, 'grid_variogram_rmse', gridfile_name, df_stats.plotbbox, df_stats.spacing, \ diff --git a/tools/RAiDER/utilFcns.py b/tools/RAiDER/utilFcns.py index c30c8d256..6923a747b 100755 --- a/tools/RAiDER/utilFcns.py +++ b/tools/RAiDER/utilFcns.py @@ -15,12 +15,12 @@ import progressbar from RAiDER.constants import ( - Zenith, - _g0 as g0, - _RE as Re, - R_EARTH_MAX as Rmax, - R_EARTH_MIN as Rmin, - ) + Zenith, + _g0 as g0, + _RE as Re, + R_EARTH_MAX as Rmax, + R_EARTH_MIN as Rmin, +) from RAiDER import Geo2rdr from RAiDER.logger import * @@ -31,6 +31,7 @@ def floorish(val, frac): '''Round a value to the lower fractional part''' return val - (val % frac) + def sind(x): """Return the sine of x when x is in degrees.""" return np.sin(np.radians(x)) @@ -48,13 +49,13 @@ def lla2ecef(lat, lon, height): def enu2ecef( - east: ndarray, - north: ndarray, - up: ndarray, - lat0: ndarray, - lon0: ndarray, - h0: ndarray, - ): + east: ndarray, + north: ndarray, + up: ndarray, + lat0: ndarray, + lon0: ndarray, + h0: ndarray, +): """ Parameters ---------- @@ -76,12 +77,12 @@ def enu2ecef( u = cosd(lon0) * t - sind(lon0) * east v = sind(lon0) * t + cosd(lon0) * east - return np.stack((u, v, w),axis=-1) + return np.stack((u, v, w), axis=-1) def ecef2enu(xyz, lat, lon, height): '''Convert ECEF xyz to ENU''' - x, y, z = xyz[...,0],xyz[...,1],xyz[...,2] + x, y, z = xyz[..., 0], xyz[..., 1], xyz[..., 2] t = cosd(lon) * x + sind(lon) * y @@ -283,7 +284,7 @@ def _geo_to_ht(lats, hts): # Calculate Geometric Height, h h = (hts * Re) / (g_ll / g0 * Re - hts) - # from metpy + # from metpy # return (geopotential * Re) / (g0 * Re - geopotential) return h @@ -429,7 +430,7 @@ def writePnts2HDF5(lats, lons, hgts, los, lengths, outName='testx.h5', chunkSize projname = 'projection' # converts from WGS84 geodetic to WGS84 geocentric - t = Transformer.from_crs(epsg, 4978, always_xy=True) + t = Transformer.from_crs(epsg, 4978, always_xy=True) checkLOS(los, np.prod(lats.shape)) in_shape = lats.shape @@ -448,22 +449,22 @@ def writePnts2HDF5(lats, lons, hgts, los, lengths, outName='testx.h5', chunkSize y = f.create_dataset('lat', data=lats, chunks=chunkSize, fillvalue=noDataValue) z = f.create_dataset('hgt', data=hgts, chunks=chunkSize, fillvalue=noDataValue) los = f.create_dataset( - 'LOS', - data=los, - chunks=chunkSize + (3,), + 'LOS', + data=los, + chunks=chunkSize + (3,), fillvalue=noDataValue ) lengths = f.create_dataset( - 'Rays_len', - data=lengths, - chunks=x.chunks, + 'Rays_len', + data=lengths, + chunks=x.chunks, fillvalue=noDataValue ) sp_data = np.stack(t.transform(lons, lats, hgts), axis=-1).astype(np.float64) sp = f.create_dataset( - 'Rays_SP', + 'Rays_SP', data=sp_data, - chunks=chunkSize + (3,), + chunks=chunkSize + (3,), fillvalue=noDataValue ) @@ -789,11 +790,11 @@ def write2NETCDF4core(nc_outfile, dimension_dict, dataset_dict, tran, mapping_na dimensions = () var = nc_outfile.createVariable( - mapping_name, - datatype, - dimensions, - fill_value=None - ) + mapping_name, + datatype, + dimensions, + fill_value=None + ) # variable made, now add attributes var.setncattr('grid_mapping_name', grid_mapping) @@ -864,13 +865,13 @@ def convertLons(inLons): def read_NCMR_loginInfo(filepath=None): - + from pathlib import Path - + if filepath is None: - filepath = str(Path.home())+'/.ncmrlogin' + filepath = str(Path.home()) + '/.ncmrlogin' - f = open(filepath,'r') + f = open(filepath, 'r') lines = f.readlines() url = lines[0].strip().split(': ')[1] username = lines[1].strip().split(': ')[1] @@ -879,14 +880,15 @@ def read_NCMR_loginInfo(filepath=None): return url, username, password - pbar = None + + def show_progress(block_num, block_size, total_size): global pbar if pbar is None: pbar = progressbar.ProgressBar(maxval=total_size) pbar.start() - + downloaded = block_num * block_size if downloaded < total_size: pbar.update(downloaded) @@ -902,9 +904,8 @@ def getChunkSize(in_shape): cpu_count = mp.cpu_count() chunkSize = tuple( max( - min(maxChunkSize, s // cpu_count), + min(maxChunkSize, s // cpu_count), min(s, minChunkSize) ) for s in in_shape ) return chunkSize - From fe73717a37dc7c420490aa9afa2acc4d5c19fa59 Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Fri, 6 Aug 2021 16:18:28 -0500 Subject: [PATCH 26/27] add in dummy file; github does not like using dummy.txt --- test/scenario_3/incorrect_file.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/scenario_3/incorrect_file.txt diff --git a/test/scenario_3/incorrect_file.txt b/test/scenario_3/incorrect_file.txt new file mode 100644 index 000000000..54e2b78c2 --- /dev/null +++ b/test/scenario_3/incorrect_file.txt @@ -0,0 +1 @@ +this is a dummy file From 53f2afa954bc4f98ede251a091237bb523c8cfe3 Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Fri, 6 Aug 2021 16:19:36 -0500 Subject: [PATCH 27/27] update unit test --- test/test_losreader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_losreader.py b/test/test_losreader.py index 0790baac5..3a2b3fb92 100644 --- a/test/test_losreader.py +++ b/test/test_losreader.py @@ -124,7 +124,7 @@ def test_get_sv_2(svs): def test_get_sv_3(svs): true_svs, ref_time = svs - filename = os.path.join(SCENARIO_DIR, 'dummy.txt') + filename = os.path.join(SCENARIO_DIR, 'incorrect_file.txt') with pytest.raises(ValueError): get_sv(filename, ref_time)