Matlab CEOS State Vector Reader I had this particular dataset from Radarsat that I wanted to process badly but for some reason Doris and I couldn't agree on the satellites orbit. For starters, state vectors are vectors that tell us about the satellites state, or in English, where the satellite is and how fast it is traveling. Since there are three dimensions in space and one dimension (or something similar) in time, state vectors constitute from time, position in x, y and z, and velocity in x, y, z dimensions.
So what was wrong with the dataset that I was trying to process? In order to process some interferograms with Doris I need the satellite data in SLC format. And since there are not precise orbits for Radarsat I have to continue with the orbits available in the leader file. The problem was that the orbits did not make sense, timing was correct but the reported positions and the velocities were totally meaningless, to the extent that the satellite was going from one side of the earth to the other and then back to the first side in 16 minutes. In order to figure out what was wrong with my data set I wrote couple Matlab scripts to read required fields from the leader files and plot them. Here I'll talk about those scripts, what they do, and how I used them. The first script that I wrote was ReadSV.m. This script can read state vectors from leader files of Radarsat raw and slc products as well as ORB orbit files. Don't worry about the ORB files too much, they are files that can be obtained by RIPRI, if you are operating a ground receiving station. ReadSV can read leader (*.lea) files of Radarsat-1 RAW and SLC products. It then outputs the state vectors in a NumberOfStateVectors x 7 matrix (generally 15x7). Seven columns are: Time, X Pos, Y Pos, Z Pos, X Vel, Y Vel, Z Vel. Usage is like this: StateVectors=ReadSV(LeaderFile) StateVectors=ReadSV(OrbFile) And here is an example: SV55960_lo=ReadSV('l0/LEA_01.001'); Reading CEOS Leader File: l0/LEA_01.001 NumSV: 15 SVStart: 9516.476000000000568 Interval: 480.000000000000000 GMHA: 342.324700095167429
Reading the state vectors is one thing, but then we need to compare them so that we can see what is going on right? So I wrote CompareSV.m. It is a very simple command, it takes two state vectors as input, and it plots two figures each with three subplots. As you can imagine, the first set of plots are for X, Y, and Z positions of both state vectors, and the second set of plots are for the velocities. Trying to figure out the problem I read the state vectors from leader files of both raw and slc products. Surprisingly they did not match. It is weird because you would expect a perfect match since it is actually the same scene! The satellite can not be at two different places at the same time right? Below is a screenshot of what I got from compareSV. That didn't really make sense. And of course before I even got to this point, I was trying to process this SLCs using Doris. Obviously it was a nightmare. I first though that there was a byte offset or something like that in the SLC files. In order to investigate that, I wanted to be able to compare Doris Output (Earth Fixed) with the State Vectors that I think were correct. Hence I wrote a script to do this. Inertial2EarthFixed.m does exactly this. It has the same algorithm used in Doris, and it outputs the EarthFixed state vectors. Usage is relatively simple: [EarthFixedSV]=Inertial2EarthFixed(StateVectors, GreenwichMeanHourAngle) As you might have noticed it requires the Greenwich Mean Hour Angle to work properly. This value is dumped to Command Window in matlab when you read the leader files with ReadSV.m, so there is nothing to worry. Then I had the moment of revelation! Looking at the CompareSV plots, I noticed that the first point of X-Pos and last point of Z-Vel were exactly the same. This meant that I must be reading the values correctly so there were no bit shifting or wrong offset errors. Think about it, somehow I was getting the very first and the very last points correct but none of the others. Then I figured it out. It was a simple matrix transpose operation. State vectors are saved in leader files like a 1D array, even though it is indeed a 2D array. For example, in ReadSV.m we output the data as a 2D array, time being the first dimension and 6 columns (x,y,z pos and x,y,z vel) being the second dimension. But when this was written in the leader file, it was written like a 1D array row by row. So if someone forgets to transpose the matrix, the first element would be the same as the first element of the transposed matrix. The same is true for the last element. But all the others would be shifted/misplaced. I tried to explain this below, using MS Excel. Now that I figured out the problem, I could sleep peacefully. I went ahead and wrote a CorrectSV.m as well. But I haven't finished testing it. So use it at your own risk, if you want to. ;) Below is the description for CorrectSV.m % Usage: % [NewStateVectors]=CorrectSV(LeaderFile, ['shift', shiftAmount], ['orb','OrbitFile'], '['lea' 'LeaderFile2']) % % Description: % NewStateVectors=CorrectSV(LeaderFile) will read the state vectors from % the current leader file and write a new "LeaderFile.new" file with the % same exact state vectors. A copy of the state vectors will be the output. % % NewStateVectors array has 7 columns for each State Vector. Colums % correspond to Time, Positions X, Y, and Z, Velocities X, Y, and Z. % % NewStateVectors=CorrectSV(LeaderFile, 'shift', N) will read the state % vectors from the Leader file, shifts them N seconds in time and outputs % the new state vectors both as the NewStateVectors array and % "LeaderFile.new" file. % % NewStateVectors=CorrectSV(LeaderFile, 'orb', 'OrbitFile') will read % state vectors from OrbitFile and write them in the new LeaderFile.new % file. % % NewStateVectors=CorrectSV(LeaderFile, 'lea', 'LeaderFile2') will read the % state vectors from LeaderFile2 and will exchange them with the ones in % LeaderFile and write a new LeaderFile.new file. % % See Also: % CompareSV Related Files
ReadSV.m CompareSV.m Inertial2EarthFixed.m CorrectSV.m Related Websites Naval Postgraduate School - Space Systems Academic Group Online lectures about orbits, astrodynamics and etc. Radarsat Data Product Specifications Information about CEOS format, byte offsets of each field and record etc. |