cedadev / swallow

Swallow - a Birdhouse WPS for running the NAME Trajectory code.
Other
0 stars 1 forks source link

fix trajectory plot labels #41

Closed alaniwi closed 2 years ago

alaniwi commented 2 years ago

Trajectory plot title says:

Forward Trajectories: Release location:

In the first place that the lon value appears, presumably something else is meant to appear there. Find out what it should be, and whether this is something we can fix or needs to be fed back re ADAQ.

agstephens commented 2 years ago

Info from AJ:

The problem was due to a change in the labelling functionality in our more recent release of ADAQ python – but it was hidden away in one of the lower-level routines, and the top-level script/documentation haven’t been updated!

In terms of the WPS interface, I think we just need to change the specification of release_info_list on line 118 of wps_run_name_trajectory.py to return the known_location instead of the lat/lon/time (which now get picked up directly from the Iris cube in the newer release). It’s a little more complicated than this– as the variable might be None (if the user gives a lat-lon rather than a location name), and we would want to pass the list [None] rather than [‘None’].

So I think the correct coding should be to remove the variable defs for lonstr, latstr and timestr in _get_adaq_scripts_and_args() and instead define:

location = input_params[‘known_location’]
if location != None and location != self._null_label:
    site = f’”{location}”’
else:
    site = None

Note the double-quote inside the single-quoted string above. Then later on

release_info_list = [ {site} ]

I don’t have time today, but I could probably have a go next week at making this change in a forked copy and passing it back for testing. I’ve checked the basic python, and it works:

>>> location = 'here'
>>> if location != None:
...     site = f'"{location}"'
... else:
...     site = None
... 
>>> release_info_list = f'[ {site} ]'
>>> print(release_info_list)
[ "here" ]
>>> location = None  
>>> if location != None:
...     site = f'"{location}"'
... else:
...     site = None
... 
>>> release_info_list = f'[ {site} ]'
>>> print(release_info_list)
[ None ]
agstephens commented 2 years ago

@alaniwi: Please pick this up when you are working on NAME.

alaniwi commented 2 years ago

Implemented using:

        location = input_params['known_location']
        site = f'"{location}"' if location not in (None, self._null_label) else None

Now get:

If named location used: image

If lat, lon given: image

This looks okay.