4 from datetime
import datetime
as DT
48 sys.exit(
'qtpow: Invalid array size')
51 sinth = np.sqrt(np.sum(np.power(v, 2), axis=1))
52 th = np.arctan2(sinth, q[:, 3])
56 rat[wh] = np.sin(np.multiply(pwr[wh], th[wh]))/sinth[wh]
57 q1 = np.zeros(q.shape)
58 q1[:, 3] = np.cos(np.multiply(th, pwr))
59 q1[:, 0:3] = np.multiply(np.tile(rat, (3, 1)).T, v)
63 def qtmult(aqt, bqt, inverse1=0, inverse2=0):
64 '''This will only work with hico'''
68 print(
'sz1,sz2=', sz1, sz2)
69 if sz1[0] < 1
or sz2[0] < 1:
70 sys.exit(
'ERROR A: Q1 and Q2 must be quaternions')
71 if sz1[1] != 4
or sz2[1] != 4:
72 sys.exit(
'ERROR B: Q1 and Q2 must be quaternions')
77 if n1 != n2
and n1 != 1
and n2 != 1:
78 sys.exit(
'ERROR: Q1 and Q2 must both have the same number of quaternions')
81 cqt = np.zeros(aqt.shape)
82 aqt0 = np.squeeze(aqt[:, 0])
83 aqt1 = np.squeeze(aqt[:, 1])
84 aqt2 = np.squeeze(aqt[:, 2])
85 aqt3 = np.squeeze(aqt[:, 3])
87 bqt0 = np.squeeze(bqt[:, 0])
88 bqt1 = np.squeeze(bqt[:, 1])
89 bqt2 = np.squeeze(bqt[:, 2])
90 bqt3 = np.squeeze(bqt[:, 3])
104 cqt[:, 0] = np.squeeze([np.multiply(aqt0, bqt3) + np.multiply(aqt1, bqt2) -
105 np.multiply(aqt2, bqt1) + np.multiply(aqt3, bqt0)])
106 cqt[:, 1] = np.squeeze([-np.multiply(aqt0, bqt2) + np.multiply(aqt1, bqt3) +
107 np.multiply(aqt2, bqt0) + np.multiply(aqt3, bqt1)])
108 cqt[:, 2] = np.squeeze([np.multiply(aqt0, bqt1) - np.multiply(aqt1, bqt0) +
109 np.multiply(aqt2, bqt3) + np.multiply(aqt3, bqt2)])
110 cqt[:, 3] = np.squeeze([-np.multiply(aqt0, bqt0) - np.multiply(aqt1, bqt1) -
111 np.multiply(aqt2, bqt2) + np.multiply(aqt3, bqt3)])
146 nq = np.int(q0.size / 4)
148 return np.tile(q0.T, (t1.size, 1))
150 qdiff =
qtmult(q0[0:nq-1, :], q0[1:, :], inverse1=1)
154 qdiff[wh, 3] = -qdiff[wh, 3]
157 hh = np.zeros(len(t1))
162 for i
in np.arange(0, len(ii)):
163 if ii[i] > 0
and ii[i] < nq-1:
164 hh[i] = (t1[i] - t0[ii[i]]) / (t0[ii[i] + 1] - t0[ii[i]])
166 ii3 = (ii2[ii2 < nq-1])
167 return qtmult(q0[ii3, :],
qtpow(qdiff[ii3, :], hh[ii3]))
172 Equivalent to IDL's value_locate routine. Excerpt from exelis follows
173 "The VALUE_LOCATE function finds the intervals within a given monotonic
174 vector that brackets a given set of one or more search values."
175 Assumes vec and val are 1D arrays
177 return np.amax([np.where(v >= vec, np.arange(len(vec)), -1)
178 for v
in vals], axis=1)
183 Takes a date and time strings and returns a datetime object"""
184 ds =
','.join([
str(
int(x))
for x
in date + time])
186 return DT.strptime(ds,
'%Y,%m,%d,%H,%M,%S')
188 print(
'Conversion error. Check validity of date/time entries:')
189 keys = [
'yr',
'mo',
'day',
'hr',
'min',
'sec']
190 for key, entry
in zip(keys, ds.split(
',')):
191 print(
'%s: %s' %(key, entry))
196 with open(refHdrFile)
as f:
198 fline = lines.find(
'odrc_time_offset')
200 return float(lines[fline:].split(
'\n')[0].split(
'=')[1].strip())
206 Class to replace command line argument parser for IPython calls.
207 Example Usage: args=Namespace(ifile='',opath='',prsil='',prnoi='')
208 **kwargs can be anything needed
212 self.__dict__.
update(kwargs)