ratt-ru / meqtrees

A library for implementing radio astronomical Measurement Equations
http://meqtrees.net
10 stars 2 forks source link

Printing out pointing errors #882

Closed PhilippaHartley closed 5 years ago

PhilippaHartley commented 5 years ago

Is there a way to inspect the pointing errors that get applied? Thanks

PhilippaHartley commented 5 years ago

I can see the error using the bookmarks in the GUI, but I would like to be able to write them out.

o-smirnov commented 5 years ago

I'm on the road right now, so I can't do a proper PR or anything.... but if you just want to write them out, you can hack the code yourself if you're feeling brave. It's really simple actually.

The errors are generated here. In fact I see we already have an option to dump them in the RandomPolc case: https://github.com/ska-sa/meqtrees-cattery/blob/master/Cattery/Siamese/OMS/ErrorGens.py#L174

If you're using some other error generator type, you can just hardcode an open("file.txt").write(xxx) statement into the appropriate make_node() function.

Let me know if you run into trouble, I'll be online later tonight.

PhilippaHartley commented 5 years ago

Thanks Oleg! I saw the option in the Polc case but what I would like to do is print out the error for each integration; I think the file dump in ErrorGens only writes out the values passed to the .Parm object - similarly, in for example SineError, I can get the values of the amplitude and offset etc, but the values applied at each integration time-stamp do not seem to be accessible until the node has been created and the simulation run? I have wandered down the rabbit holes of the lower layers but wasn't successful in printing out. I tried to print out values that appear in the inspectors, but I can only get the first four values of each antenna (since only the first four values for each antenna appear in the dlm inspector).

PhilippaHartley commented 5 years ago

This is closely related to something else I was trying to do, which was to read in a list of random dynamic errors using ListOfValues. So I have n*m values of dlm, where n is number of antennae, and m is number of time-stamps. But LIstOfValues only passes in the values for the first timestamp. I've tried to access time-varying functionality by experimenting with SineError (which uses .Time()) and I can hard code a crude radnom number generator in there, which using a random number and the .Time as seeds. The output isn't random enough though.

Any help would be very appreciated, many thanks!

o-smirnov commented 5 years ago

Ah I see. I think you're pushing those old toy error generators beyond where they were designed to go...

I think the easiest and cleanest solution is to make a custom error generator using a PyNode. Then you'll have full control and flexibility.

Boarding now, I'll give more pointers when I get to a laptop. There's a few PyNode examples scattered in Cattery if you want to try to work it out for yourself.

Cheers, Oleg


Sent from my phone. Quality of spelling inversely proportional to finger size.

On Thu, 23 May 2019, 14:27 PhilippaHartley, notifications@github.com wrote:

This is closely related to something else I was trying to do, which was to read in a list of random dynamic errors using ListOfValues. So I have n*m values of dlm, where n is number of antennae, and m is number of time-stamps. But LIstOfValues only passes in the values for the first timestamp. I've tried to access time-varying functionality by experimenting with SineError (which uses .Time()) and I can hard code a crude radnom number generator in there, which using a random number and the .Time as seeds. The output isn't random enough though.

Any help would be very appreciated, many thanks!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ska-sa/meqtrees/issues/882?email_source=notifications&email_token=ABRLTPYMDJMOZ2A76VXYR3LPW2EUZA5CNFSM4HOSGJA2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWCB2SQ#issuecomment-495197514, or mute the thread https://github.com/notifications/unsubscribe-auth/ABRLTPYZS6GZ6BQH2LSUJU3PW2EUZANCNFSM4HOSGJAQ .

PhilippaHartley commented 5 years ago

Nice, will have a look - thank you Oleg!

PhilippaHartley commented 5 years ago

A quick update:

I made a workaround which writes out all the pointing errors. It uses the file Grid/__init__.py in the Timba package. The relevant code is

  def update (self,data):
    dicti2 = data['cache'];
    dicti1 = dicti2['result'];
    dicti = dicti1['vellsets'];
    if len(dicti)==394:
        if len(dicti[0]['value'])==65:
            if 1:
                for count, vellset in enumerate(dicti):
                    if count % 2 ==0:
                        a = np.array(vellset['value']);
                    else:
                        b =  np.array(vellset['value']);
                        landm = np.hstack((a,b))
                        try:
                            landm_arr = np.hstack((landm_arr, landm.T))
                        except:
                            landm_arr = landm.T
np.save('meqtrees_dlm', landm_arr)

This will write write out a numpy array -- meqtrees_dlm.npy -- of pointing errors with the shape (2, mxn), where each column contains 2 pointing errors, dl and dm, and each row contains values ordered first by by timestamp m and then by antenna m:

Thanks again for your help - in the future I will have a go at writing a bespoke function to do this if I need it again.