Closed Mikejmnez closed 1 year ago
I created a function on PR #286 that takes the extracted data from the poseidon viewer. The PR is already merged and works is as follows:
lon, lat = viewer_to_range(p)
where the variable p
contains the data extracted directly from the poseidon viewer.
This approach follows item # 1 above. Meaning, the variable p
is not passed as an argument into oceanspy
. Instead the user must extract longitude and latitudes from variable p
via viewer_to_range
I am leaving this issue open, so people can comment, particularly on whether the approach # 2 detailed above is of interest. It will take some work but should be pretty easy. For now, oceanspy + poseidon viewer
already work together.
I am uploading a working notebook into shared notebooks
. The notebook is called Ospy_PoseidonViewer.ipynb
. I also added three png files (Polygon.png
, LineString.png
and Point.png
) that illustrate the way I extracted the three different objects / Data/section from the poseidon viewer.
With the poseidon issues resolved (see https://github.com/sciserver/poseidon-viewer/issues/4 for a description of the previous errors), we can now import the data from a jupyter notebook cell as follows:
from poseidon_viewer import get_shapes
p = get_shapes()
This approach is different from the way I described originally the integration of poseidon_viewer with oceanspy (see above), which relies on using keyboard shortcuts (ctrl+c or command+c) to paste the data copied from the poseidon viewer into a cell. Moreover, while the two approaches yield the same data, the types are different...
>> p1 = [{"type":"Polygon","coordinates":[[[-44.93392070484584,3.829744170820163],[-44.93392070484584,-44.89627001277938],[10.83700440528633,-45.45524212082172],[8.458149779735672,4.093429555257572],[-44.93392070484584,3.829744170820163]]]}]
>> type(p1)
list
get_shapes()
:
>> p2 = get_shapes()
>> type(p2)
str
When I wrote (and tested) the function viewer_to_range(p)
, which takes the data from the poseidon viewer and extracts lat and lon arrays, I wrote this function so that it takes a list
as argument. The issue ( https://github.com/sciserver/poseidon-viewer/issues/4) was either unfixed or I didn't know it was fixed. As a result, viewer_to_range(p)
is NOT compatible with get_shapes()
.
Solution is super simple, a single line. But it will require also a test.
Expect a PR soon!
closed by #300
Description
We need to integrate the Poseidon viewer with oceanspy. There remain unresolved issues with the poseidon viewer since Sept 4th , see here: https://github.com/sciserver/poseidon-viewer/issues/4
Nonetheless, Mitya pointed out that we can still extract the coordinates from the
poseidon viewer
app. To do this, we first need to:polygon
orline
on the app.ctrl+c
(orcommand+c
). It is best to assigned first a variable. For now lets call it (by convention, the way Mytia first called it) pThere are three types of data selection from the Poseidon Viewer. These are:
Polygon.
See example below:
A LineString
See example below:
A Point
One a notebook, the data looks like:
The above snapshot is for the first example. You can tell because the extracted data contains information about the nature of the shape (
'type':'Polygon'
).What I Did
To integrate the poseidon viewer with oceanspy, we need to extract the coordinates from the variable p. There are two ways I can think of:
create a function
poseidon_to_range()
that returns the desired data in the right format for oceanspy. This is:Then
lon
andlat
are passed as arguments into oceanspy.Modify each function within
oceanspy.subsample
(e.g. cutout, mooring, survey) so thatp
can be used as an argument. That is, the above function_poseidon_to_range(p)
is called internally byoceanspy.subsample.fn
. This has the advantange that there is minimal difference from the user point of view.I decided to follow 1, the simplest way. We can always do 2 later. Expect a PR soon enough