asfadmin / Discovery-asf_search

BSD 3-Clause "New" or "Revised" License
126 stars 44 forks source link

Beam mode does not work with geo-search? #38

Closed cmarshak closed 2 years ago

cmarshak commented 3 years ago

Awesome tool!

Is this the expected behavior?

import asf_search as asf
from shapely.geometry import box
from dateparser import parse
import pandas as pd

# bay area
bounds: list = [-121.5, 34.95, -120.2, 36.25]
start_str: str = '2021-06-02'
end_str: str = '2021-06-09'

box_geo = box(*bounds)
start = parse(start_str)
end = parse(end_str)

results = asf.geo_search(platform=[asf.PLATFORM.SENTINEL1],
                         intersectsWith=box_geo.to_wkt(),
                         start=start,
                         end=end,
                         maxResults=100,
                         beamMode=[asf.BEAMMODE.IW]
                        )
df = pd.DataFrame([r.properties for r in results])

df.beamModeType.unique()

The output is array(['IW', 'slc'], dtype=object).

glshort commented 3 years ago

Hi Charlie, glad you’re enjoying the tool, even in its infancy.

If I’m reading this correctly, it looks like you’re seeing some unexpected results when doing a search restricted by beam mode, specifically some products are coming back with a beamModeType property of slc (looks like S1 InSAR products specifically.)

This appears to be a bug in how a couple fields were being handled in our REST API that asf_search communicates with, specifically beamMode vs. beamModeType. Most of our datasets conflate the two, but the S1 InSAR dataset has different values, as you see with the slc beamModeType property. What should be happening is that there should instead be a beamMode property in your results with the correct value.

We’ll take a closer look to confirm all this and assuming it all checks out, we’ll push a change that should fix it right away. For this one, since the data is coming from our REST API, no update to asf_search will be required, we’ll simply add the new beamMode field at our end via the backend REST API. Once you’ve had a chance to make any required changes, only then will we phase out the erroneous beamModeType property.

That is to say, once we have pushed this fix, the only change to your code should be the last line, which would become:

df.beamMode.unique()

Additionally, I’m going to guess you didn’t actually want to include those S1 InSAR products in your search results. To alleviate that, I recommend including instrument=[asf.INSTRUMENT.C_SAR] as a search parameter. You’ll need to update asf_search to v2.0.2 for the instrument constants, which we'll push out first thing Wednesday morning (see: pull request https://github.com/asfadmin/Discovery-asf_search/pull/41). I’ll expose that value in the results properties as well, no update will be needed for that at your end.

Let us know if you have any further questions or concerns with this, and we’ll let you know as soon as we’ve applied a fix.