aerospaceresearch / orbitdeterminator

determination of satellite orbits and more
MIT License
185 stars 113 forks source link

add more IOD formats #193

Open hornig opened 4 years ago

hornig commented 4 years ago

https://github.com/aerospaceresearch/orbitdeterminator/blob/5a2c2a6efce5710e5cb22a90a76e4c0ea0ea4de1/orbitdeterminator/kep_determination/gauss_method.py#L218-L247

read first line, get sub-format, construct iod_delims from there as it is now, it only works for the given test file iod_data.txt iod_delims are the fixed-width column delimiter followinf IOD format description

IOD formats explained here http://www.satobs.org/position/IODformat.html

hornig commented 4 years ago

I added some already. some more need to be finished. https://github.com/aerospaceresearch/orbitdeterminator/tree/Positional_Obs_Report_Formats

grubdragon commented 3 years ago

Hi! Is this issue still open? i'm a newbie, where should I start?

KingShark1 commented 3 years ago

Is the issue still open ?

hornig commented 3 years ago

It is open as long as we do not close it. So feel free to add more and make it more elegant.

KingShark1 commented 3 years ago

I was looking into the issue, found that for the conversion to work, four variables are required, namely : elevation, azimuth, UTC time and finally Latitude.

the data provided would already contain three of them excluding Latitude, as latitude would be of the observing station, it would be required to calculate the siderial time and also both of elevation and azimuth.

here is the code taken from https://github.com/aerospaceresearch/orbitdeterminator/tree/Positional_Obs_Report_Formats and modified def load_iod_data(fname):
""" Loads satellite position observation data files following the Interactive Orbit Determination format (IOD). Currently, the only supported angle format are 1,2,3&7, as specified in IOD format. IOD format is described at http://www.satobs.org/position/IODformat.html. TODO: convert IOD angle formats 4,5&6 from AZ/EL to RA/DEC. Args: fname (string): name of the IOD-formatted text file to be parsed Returns: x (numpy array): array of satellite position observations following the IOD format, with angle format code = 2. """ import math

      # dt is the dtype for IOD-formatted text files
      dt = 'S15, i8, S1, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, S8, S7, i8, i8, S1, S1, i8, i8, i8'

      # iod_names correspond to the dtype names of each field
      iod_names = ['object', 'station', 'stationstatus',
                      'yr', 'month', 'day',
                      'hr', 'min', 'sec', 'msec', 'timeM', 'timeX',
                      'angformat', 'epoch',
                      'raaz', 'decel', 'radecazelM', 'radecazelX',
                      'optical', 'vismagsign', 'vismag', 'vismaguncertainty', 'flashperiod']

      # iod_delims corresponds to the delimiter for cutting the right variable from each input string
      iod_delims = [15, 5, 2,
                      5, 2, 2,
                      2, 2, 2, 3, 2, 1,
                      2, 1,
                      8, 7, 2, 1,
                      2, 1, 3, 3, 9]

      iod_input_lines = np.genfromtxt(fname, dtype=dt, names=iod_names, delimiter=iod_delims, autostrip=True)

      def horizon_to_celestial(ele, al, utc, lat):
          """ele : elevation
              al : altitude
              AZ/EL  = DDDMMSS+DDMMSS MX   (MX in seconds of arc)
              st : siderial time
              lat: latitude
              returns right_ascension and declination in order
          """
          #todo convert utc to siderial_time(ST)
          ELE = math.radians(ele)
          AL = math.radians(al)
          LAT = math.radians(lat)
          ST = math.radians(-1*utc)

          sin_dec = (math.sin(LAT)*math.sin(ELE)) + (math.cos(LAT)*math.cos(ELE)*math.cos(AZ))
          dec = math.degrees(math.asin(sin_dec))

          cos_HA = (math.sin(ELE) - math.sin(LAT)*sin_dec)/(math.cos(LAT)*math.cos(math.asin(sin_dec)))
          HA = math.degrees(math.acos(cos_HA))
          #if the object is west of observer's meridian
          if():
              ra = ST - HA
          #if the object is east of observer's meridian
          else:
              ra = ST + HA

          return ra, dec

      right_ascension = []
      declination = []
      azimuth = []
      elevation = []

      for i in range(len(iod_input_lines)):

          RA = -1.0
          DEC = -1.0
          AZ = -1.0
          EL = -1.0

          if iod_input_lines["angformat"][i] == 1:
              # 1: RA/DEC = HHMMSSs+DDMMSS MX   (MX in seconds of arc)
              RAAZ = iod_input_lines["raaz"][i].decode()
              HH = float(RAAZ[0:2])
              MM = float(RAAZ[2:4])
              SS = float(RAAZ[4:6])
              s = float(RAAZ[6])
              RA = (HH + (MM + (SS + s / 10.0) / 60.0) / 60.0) / 24.0 * 360.0

              DECEL = iod_input_lines["decel"][i].decode()
              DD = float(DECEL[1:3])
              MM = float(DECEL[3:5])
              SS = float(DECEL[5:7])
              DEC = DD + (MM + SS / 60.0) / 60.0
              if DECEL[0] == "-":
                  DEC = -1.0 * DEC

          elif iod_input_lines["angformat"][i] == 2:
              # 2: RA/DEC = HHMMmmm+DDMMmm MX   (MX in minutes of arc)
              RAAZ = iod_input_lines["raaz"][i].decode()
              HH = float(RAAZ[0:2])
              MM = float(RAAZ[2:4])
              mmm = float(RAAZ[4:7])
              RA = (HH + (MM + mmm / 1000.0) / 60.0) / 24.0 * 360.0

              DECEL = iod_input_lines["decel"][i].decode()
              DD = float(DECEL[1:3])
              MM = float(DECEL[3:5])
              mm = float(DECEL[5:7])
              DEC = DD + (MM + mm / 100.0) / 60.0
              if DECEL[0] == "-":
                  DEC = -1.0 * DEC

          elif iod_input_lines["angformat"][i] == 3:
              # 3: RA/DEC = HHMMmmm+DDdddd MX   (MX in degrees of arc)
              RAAZ = iod_input_lines["raaz"][i].decode()
              HH = float(RAAZ[0:2])
              MM = float(RAAZ[2:4])
              mmm = float(RAAZ[4:7])
              RA = (HH + (MM + mmm / 1000.0) / 60.0) / 24.0 * 360.0

              DECEL = iod_input_lines["decel"][i].decode()
              DD = float(DECEL[1:3])
              dddd = float(DECEL[3:7])
              DEC = (DD + (dddd / 1000.0))
              if DECEL[0] == "-":
                  DEC = -1.0 * DEC

          elif iod_input_lines["angformat"][i] == 4:
              # 4: AZ/EL  = DDDMMSS+DDMMSS MX   (MX in seconds of arc)
              RAAZ = iod_input_lines["raaz"][i].decode()
              DDD = float(RAAZ[0:3])
              MM = float(RAAZ[3:5])
              SS = float(RAAZ[5:7])
              AZ = DDD + (MM + SS / 60.0) / 60.0

              DECEL = iod_input_lines["decel"][i].decode()
              DD = float(DECEL[1:3])
              MM = float(DECEL[3:5])
              SS = float(DECEL[5:7])
              EL = DD + (MM + SS / 60.0) / 60.0
              if DECEL[0] == "-":
                  EL = -1.0 * EL
              UTC = float()
              # TODO: convert from AZ/EL to RA/DEC
              RA, DEC = horizon_to_celestial(EL, AZ, UTC, LAT)

          elif iod_input_lines["angformat"][i] == 5:
              # 5: AZ/EL  = DDDMMmm+DDMMmm MX   (MX in minutes of arc)
              RAAZ = iod_input_lines["raaz"][i].decode()
              DDD = float(RAAZ[0:3])
              MM = float(RAAZ[3:5])
              SS = float(RAAZ[5:7])
              AZ = DDD + (MM + SS / 60.0) / 60.0

              DECEL = iod_input_lines["decel"][i].decode()
              DD = float(DECEL[1:3])
              MM = float(DECEL[3:5])
              mm = float(DECEL[5:7])
              EL = DD + (MM + mm / 100.0) / 60.0
              if DECEL[0] == "-":
                  EL = -1.0 * EL

              # TODO: convert from AZ/EL to RA/DEC
              RA, DEC = horizon_to_celestial(EL, AZ, UTC, LAT)

          elif iod_input_lines["angformat"][i] == 6:
              # 6: AZ/EL  = DDDdddd+DDdddd MX   (MX in degrees of arc)
              RAAZ = iod_input_lines["raaz"][i].decode()
              DDD = float(RAAZ[0:3])
              dddd = float(RAAZ[3:7])
              AZ = DDD + dddd / 1000.0

              DECEL = iod_input_lines["decel"][i].decode()
              DD = float(DECEL[1:3])
              dddd = float(DECEL[3:7])
              EL = DD + dddd / 1000.0
              if DECEL[0] == "-":
                  EL = -1.0 * EL

              # TODO: convert from AZ/EL to RA/DEC
              RA, DEC = horizon_to_celestial(EL, AZ, UTC, LAT)

          elif iod_input_lines["angformat"][i] == 7:
              # 7: RA/DEC = HHMMSSs+DDdddd MX   (MX in degrees of arc)
              RAAZ = iod_input_lines["raaz"][i].decode()
              HH = float(RAAZ[0:2])
              MM = float(RAAZ[2:4])
              SS = float(RAAZ[4:6])
              s = float(RAAZ[6])
              RA = (HH + (MM + (SS + s / 10.0) / 60.0) / 60.0) / 24.0 * 360.0

              DECEL = iod_input_lines["decel"][i].decode()
              DD = float(DECEL[1:3])
              dddd = float(DECEL[3:7])
              DEC = (DD + (dddd / 1000.0))
              if DECEL[0] == "-":
                  DEC = -1.0 * DEC

          #else:
          #    # TODO: when not defined, we assume it is RA/DEC

          right_ascension.append(RA)
          declination.append(DEC)
          azimuth.append(AZ)
          elevation.append(EL)

      # expanding the input iod data with the position data in different formats
      iod = {}
      for name in iod_names:
              iod[name] = iod_input_lines[name].tolist()

      iod["right_ascension"] = right_ascension
      iod["declination"] = declination
      iod["azimuth"] = azimuth
      iod["elevation"] = elevation

      return iod
hornig commented 3 years ago

Hi, okay, cool.

Why not making a PR out of all your efforts?

It's also easier to read. It's easier to see changes. And we can test it with your branch.

Will you?

KingShark1 commented 3 years ago

ok, i'll make a PR, but the location(latitude and longitude) data is important, would you resolve that for me?

also i am a student from India, trying for GSoC 2021, just to let you know

hornig commented 3 years ago

ok, i'll make a PR, but the location(latitude and longitude) data is important, would you resolve that for me?

also i am a student from India, trying for GSoC 2021, just to let you know

It latitude longitude stuff is implemented in the already working part. I think you can just do it similarly. You should test your code anyways and see, if it works :). I will help of course, so doing a PR into the iod branch would be a good start. Then we can work together on this.

And I expected you to be a gsoc student. ;) We have a lot of new activity lately about it. If you did not do it already, come into our zulip chat for further chats.

KingShark1 commented 3 years ago

should i make a new branch for this? @hornig

hornig commented 3 years ago

@KingShark1 you can use the branch for the report formats.

KingShark1 commented 3 years ago

@hornig can you check up on the changes i made? here's a link to my forked repo https://github.com/KingShark1/orbitdeterminator

hornig commented 3 years ago

@KingShark1 your link is broken (underneath) and on the visible side it links to your repo. it would help me to see the change you did by either providing a link to your change/commit, or you just directly commit it as a PR to this branch https://github.com/aerospaceresearch/orbitdeterminator/tree/Positional_Obs_Report_Formats

Will have a look then. :)

KingShark1 commented 3 years ago

yeah did that! please update me soon : ) also, there's a bunch of gibberish stuff, due to my vsc enviorment, and a testing file(somethingsomething.py), ignore those two :)

hornig commented 3 years ago

would be good if you remove it :) in the end it needs to run on your computer first :).

nomaan-2k commented 2 years ago

Hey @hornig I worked on AZ/EL to RA/DEC conversion part of this issue. I have made changes on the master branch. To create a PR, should I make a new branch as this branch is quite old ( structure differs a bit from the current master branch ). Or can I create a PR on the master??