desihub / desimeter

DESI coordinates and transformations
BSD 3-Clause "New" or "Revised" License
2 stars 4 forks source link

get_posmoves error with min date and calibs #110

Closed joesilber closed 4 years ago

joesilber commented 4 years ago

get_posmoves fails for me. See console output copied below. I believe the cause is:

[msdos@beyonce desimeter-master]$ /software/products/desimeter-master/bin/get_posmoves --host XXXX --port XXXX --password XXXX --petal-ids 1 --date-min 2020-08-06 --with-calib -o ~/jhsilber/posmovedata
select * from posmovedb.positioner_calibration_p1 where pos_id='M08275' order by time_recorded
Traceback (most recent call last):
  File "/software/products/desimeter-master/bin/get_posmoves", line 99, in <module>
    j=np.where(tstamp_calib<t)[0][-1]
IndexError: index -1 is out of bounds for axis 0 with size 0
[msdos@beyonce desimeter-master]$ python -m pdb /software/products/desimeter-master/bin/get_posmoves --host XXXX --port XXXX --password XXXX --petal-ids 1 --date-min 2020-08-06 --with-calib -o ~/jhsilber/posmovedata
> /software/products/desimeter-master/bin/get_posmoves(3)<module>()
-> import os,sys
(Pdb) b 99
Breakpoint 1 at /software/products/desimeter-master/bin/get_posmoves:99
(Pdb) l
  1     #!/usr/bin/env python
  2
  3  -> import os,sys
  4     import psycopg2
  5     import numpy as np
  6     import matplotlib.pyplot as plt
  7     from astropy.table import Table
  8     import datetime
  9     import argparse
 10
 11     from desimeter.util import parse_fibers
(Pdb) c
select * from posmovedb.positioner_calibration_p1 where pos_id='M08275' order by time_recorded
> /software/products/desimeter-master/bin/get_posmoves(99)<module>()
-> j=np.where(tstamp_calib<t)[0][-1]
(Pdb) l
 94
 95                 for k in new_keys :
 96                     posmoves[k]=list()
 97
 98                 for t in tstamp_posmovedb :
 99 B->                 j=np.where(tstamp_calib<t)[0][-1]
100                     for k1,k1 in zip(new_keys,calib.keys) :
101                         posmoves[k1].append(calib[k2][j])
102
103             # save, using astropy.Table io
104
(Pdb) t
1585169115.612538
(Pdb) tstamp_calib
array([1.58516912e+09, 1.58688938e+09, 1.58689045e+09, 1.58692164e+09,
       1.58692168e+09, 1.58692171e+09, 1.58697402e+09, 1.58990817e+09,
       1.58990819e+09, 1.58990820e+09, 1.58990978e+09, 1.58990983e+09,
       1.58990984e+09, 1.58990986e+09, 1.58991030e+09, 1.58993004e+09,
       1.58993006e+09, 1.58993007e+09, 1.58993028e+09, 1.58993196e+09,
       1.58993205e+09, 1.59019717e+09, 1.59019719e+09, 1.59019721e+09,
       1.59051586e+09, 1.59068536e+09, 1.59068539e+09, 1.59068541e+09,
       1.59072267e+09, 1.59258753e+09, 1.59258755e+09, 1.59258757e+09,
       1.59355202e+09, 1.59371648e+09, 1.59413956e+09, 1.59415106e+09,
       1.59415182e+09, 1.59424257e+09])
(Pdb) np.where(tstamp_calib<t)
(array([], dtype=int64),)
(Pdb) np.where(tstamp_calib>t)
(array([ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17,
       18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
       35, 36, 37]),)
weaverba137 commented 4 years ago

This is probably not dangerous in this specific case, but it is definitely a bad habit: the command line leaked a password to the public. I took the liberty of removing the password and other potentially sensitive information.

julienguy commented 4 years ago

Fixed in master. There were typos in the code. I guess I changed this script without checking the --with-calib option was still working after some code reorganization. @joesilber please verify and close issue if it works for you.

joesilber commented 4 years ago

verified, good