adamoferro / sopa

SHARAD Open Processing Attempt
GNU General Public License v3.0
5 stars 3 forks source link

parameter interpretation #1

Open raypenper opened 2 years ago

raypenper commented 2 years ago

Hi Dr.Ferro, what does the four parameters FRAME_START, FRAME_END, METERS_SKIP and SQUINT_ANGLE mean? Do we need to change their values when simulating different EDR or RDR products?

adamoferro commented 2 years ago

Hello, Sorry for the late reply.

Simulations are based on the ancillary data included in the EDR/RDR data. FRAME_START and FRAME_END indicate the portion of the EDR/RDR you want to simulate.

METERS_SKIP is used to select which frames to simulate in the FRAME_START/_END range by indicating the space span (meters) between the frames to be simulated. If you want to simulate all the frames, just put a very small number. However as simulation is not coherent, there's no real need to simulate all the frames of a radargram. Just simulating using the final frame spacing would be ok in my opinion, avoiding processing time.

SQUINT_ANGLE is not used for simulations.

Hope this helps. Best regards, Adamo

On Mon, Apr 18, 2022 at 2:27 PM raypenper @.***> wrote:

Hi Dr.Ferro, what does the four parameters FRAME_START, FRAME_END, METERS_SKIP and SQUINT_ANGLE mean? Do we need to change their values when simulating different EDR or RDR products?

— Reply to this email directly, view it on GitHub https://github.com/adamoferro/sopa/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADG7O6JLPT6QS2VPYXEPZNDVFVIL3ANCNFSM5TVX5FLA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

raypenper commented 2 years ago

Thanks for your reply ^_^ When I intended to plot the simulation result using the function SimulationPlot, an error occurred. I checked the saved simulation result and found that the values in it are all zeros. Could you please tell me why?

image

adamoferro commented 2 years ago

It is almost impossible for me to help without more information...

If you tell me what is the radargram you are trying to simulate, and the exact command line and parameters you use, I could give it a try. Let me know!

Il mer 20 apr 2022, 16:53 raypenper @.***> ha scritto:

Thanks for your reply ^_^ When I intended to plot the simulation result using the function SimulationPlot, an error occurred. I checked the saved simulation result and found that the values in it are all zeros. Could you please tell me why?

[image: image] https://user-images.githubusercontent.com/41855946/164258153-88a2fe04-6509-45d2-bfd0-aa0eed47b769.png

— Reply to this email directly, view it on GitHub https://github.com/adamoferro/sopa/issues/1#issuecomment-1104027890, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADG7O6J3PWQTWRPVQTIF6DDVGAK6DANCNFSM5TVX5FLA . You are receiving this because you commented.Message ID: @.***>

raypenper commented 2 years ago

Sorry that I did not make it clear. I used SHARAD EDR data of south polar region for input. The whole command lines in the main function are as follows:

MOLA128_FILENAME_BASE = "I:/MarsData/MOLA/megt_s_128_1/megt_s_128_1.img"

EDR_PDS_INPUT_FILENAME_BASE = "I:/MarsData/SHARAD/edr/e_0598301_001_ss19_700_a"  # OBS folder path+base file name (without suffixes)
EDR_PDS_INPUT_DATASET_NAME = "edr0598301"
EDR_PDS_OUTPUT_SIM_FILENAME_BASE = "I:/projects/sopa-SHARADlowlevelProcessing/output/PDS-EDR-0598301_SIM.img"
EDR_PDS_OUTPUT_FOC_FILENAME_BASE = "I:/projects/sopa-SHARADlowlevelProcessing/output/PDS-EDR-0598301_FOC.img"

FRAME_START = 1000
FRAME_END = 20000
METERS_SKIP = 450
FRAME_HALF_APERTURE = 758  # use 758 for "standard" focusing with presumming = 4
SQUINT_ANGLE = 20

lg = logger(verbose=True)

# create SHARAD instrument instance
i = SHARAD()

# Mars ellipsoid characteristics
cc = MARS_IAU2000()

# the MOLA128 radius data are contained in a single ENVI file
m = MOLA128(filename_base=MOLA128_FILENAME_BASE)  # mola_mars_data.hdr
m.read()

# definition of focuser and simulator parameters
pars = FocuserParameters(frame_start=FRAME_START, frame_end=FRAME_END, meters_skip=METERS_SKIP,
                         frame_half_aperture=FRAME_HALF_APERTURE, squint_angle=SQUINT_ANGLE)

# definition of a square facets RS simulator using the Mars coordinate converter and the MOLA128 DEM
s = sfRSsim(geom_obj=cc, dem_obj=m, param_obj=pars,
            n_processes=6)  # simulation parameters are contained in the DRSSim class

# ...or dRSsim:
# s = dRSsim(geom_obj=cc, dem_obj=m, param_obj=pars, n_processes=6)       # simulation parameters are contained in the DRSSim class

# EDR PDS
fn_base = EDR_PDS_INPUT_FILENAME_BASE
d = EDR_PDS(dataset_name=EDR_PDS_INPUT_DATASET_NAME, filename_base=fn_base, logger=lg)
d.load(mode="full")
d.generate_orbit_data()
if d.orbit_data is not None:

    # plot the track path on the DEM
    # tpod = TrackPlotOnDEM(m, d.orbit_data["Lat"], d.orbit_data["Lon"], title="Spacecraft ground track on DEM (full track)")
    # tpod.plot()

    # simulate surface clutter radargram
    sim_image, uncert_image, first_return_lats, first_return_lons, ground_distance_min_image, ground_distance_max_image = s.simulate(
        d.orbit_data)

    # save results on disk
    envi.write(EDR_PDS_OUTPUT_SIM_FILENAME_BASE, sim_image)
    envi.write(EDR_PDS_OUTPUT_SIM_FILENAME_BASE + "_uncert", uncert_image)

    # plot the simulated radargram
    # only the top part of the simulation is shown (the top point is calculated dinamically)
    top_point = np.min(np.argmin(np.isnan(ground_distance_min_image).astype(int), axis=0)) - 50
    bottom_point = top_point + 1000
    sp = SimulationPlot(sim_image, top_point=top_point, bottom_point=bottom_point,
                        title="Radargram simulation with sfRSsim\n(square facets and cos^exp function)")
    sp.plot()

    # plot the track path and the location of the first simulated returns on the DEM
    tfrpod = TrackAndFirstReturnsPlotOnDEM(m, d.orbit_data["Lat"], d.orbit_data["Lon"], first_return_lats,
                                           first_return_lons)
    tfrpod.plot()

    # plot the image showing the minimum ground distance from nadir of each simulated range sample
    gdp = GroundDistancePlot(ground_distance_min_image / 1000., top_point=top_point, bottom_point=bottom_point,
                             title="Distance [km] of the closest facet contributing\nto each radargram sample simulation")
    gdp.plot()

    # get the DEM radius profile related to the spacecraft track, to be used later by the focuser
    dem_radius_profile = m.get_dem_radius_from_lat_lon(d.orbit_data["Lat"], d.orbit_data["Lon"])

    # free the memory occupied by the DEM (not mandatory, but it may be useful if system RAM is limited)
    del m

    if d.data is not None:
        # create a SOFA instance and focus the input radargram
        f = SOFA(i, cc, dem_radius_profile, d, pars, n_processes=4, debug_mode=True)
        focused_rdr = f.focus()
        if focused_rdr is not None:
            envi.write(EDR_PDS_OUTPUT_FOC_FILENAME_BASE + "_ha-" + str(pars.frame_half_aperture) + "_s-" + str(
                pars.squint_angle), focused_rdr)

            # plot the focused radargram
            rp = RadargramPlot(focused_rdr, top_point=top_point, bottom_point=bottom_point, title="Radargram")
            rp.plot()
adamoferro commented 2 years ago

How did you create the megt_s_128_1.img file? Is it an ENVI file as required?

The "t" in "megt" is suspicious: is it "topography" or "radius" (as required)?

On Sun, Apr 24, 2022 at 9:53 AM raypenper @.***> wrote:

Sorry that I did not make it clear, the whole command lines in the main function are as follows:

MOLA128_FILENAME_BASE = "I:/MarsData/MOLA/megt_s_128_1/megt_s_128_1.img"

EDR_PDS_INPUT_FILENAME_BASE = "I:/MarsData/SHARAD/edr/e_0598301_001_ss19_700_a" # OBS folder path+base file name (without suffixes) EDR_PDS_INPUT_DATASET_NAME = "edr0598301" EDR_PDS_OUTPUT_SIM_FILENAME_BASE = "I:/projects/sopa-SHARADlowlevelProcessing/output/PDS-EDR-0598301_SIM.img" EDR_PDS_OUTPUT_FOC_FILENAME_BASE = "I:/projects/sopa-SHARADlowlevelProcessing/output/PDS-EDR-0598301_FOC.img"

FRAME_START = 1000 FRAME_END = 20000 METERS_SKIP = 450 FRAME_HALF_APERTURE = 758 # use 758 for "standard" focusing with presumming = 4 SQUINT_ANGLE = 20

lg = logger(verbose=True)

create SHARAD instrument instance

i = SHARAD()

Mars ellipsoid characteristics

cc = MARS_IAU2000()

the MOLA128 radius data are contained in a single ENVI file

m = MOLA128(filename_base=MOLA128_FILENAME_BASE) # mola_mars_data.hdr m.read()

definition of focuser and simulator parameters

pars = FocuserParameters(frame_start=FRAME_START, frame_end=FRAME_END, meters_skip=METERS_SKIP, frame_half_aperture=FRAME_HALF_APERTURE, squint_angle=SQUINT_ANGLE)

definition of a square facets RS simulator using the Mars coordinate converter and the MOLA128 DEM

s = sfRSsim(geom_obj=cc, dem_obj=m, param_obj=pars, n_processes=6) # simulation parameters are contained in the DRSSim class

...or dRSsim:

s = dRSsim(geom_obj=cc, dem_obj=m, param_obj=pars, n_processes=6) # simulation parameters are contained in the DRSSim class

EDR PDS

fn_base = EDR_PDS_INPUT_FILENAME_BASE d = EDR_PDS(dataset_name=EDR_PDS_INPUT_DATASET_NAME, filename_base=fn_base, logger=lg) d.load(mode="full") d.generate_orbit_data() if d.orbit_data is not None:

# plot the track path on the DEM
# tpod = TrackPlotOnDEM(m, d.orbit_data["Lat"], d.orbit_data["Lon"], title="Spacecraft ground track on DEM (full track)")
# tpod.plot()

# simulate surface clutter radargram
sim_image, uncert_image, first_return_lats, first_return_lons, ground_distance_min_image, ground_distance_max_image = s.simulate(
    d.orbit_data)

# save results on disk
envi.write(EDR_PDS_OUTPUT_SIM_FILENAME_BASE, sim_image)
envi.write(EDR_PDS_OUTPUT_SIM_FILENAME_BASE + "_uncert", uncert_image)

# plot the simulated radargram
# only the top part of the simulation is shown (the top point is calculated dinamically)
top_point = np.min(np.argmin(np.isnan(ground_distance_min_image).astype(int), axis=0)) - 50
bottom_point = top_point + 1000
sp = SimulationPlot(sim_image, top_point=top_point, bottom_point=bottom_point,
                    title="Radargram simulation with sfRSsim\n(square facets and cos^exp function)")
sp.plot()

# plot the track path and the location of the first simulated returns on the DEM
tfrpod = TrackAndFirstReturnsPlotOnDEM(m, d.orbit_data["Lat"], d.orbit_data["Lon"], first_return_lats,
                                       first_return_lons)
tfrpod.plot()

# plot the image showing the minimum ground distance from nadir of each simulated range sample
gdp = GroundDistancePlot(ground_distance_min_image / 1000., top_point=top_point, bottom_point=bottom_point,
                         title="Distance [km] of the closest facet contributing\nto each radargram sample simulation")
gdp.plot()

# get the DEM radius profile related to the spacecraft track, to be used later by the focuser
dem_radius_profile = m.get_dem_radius_from_lat_lon(d.orbit_data["Lat"], d.orbit_data["Lon"])

# free the memory occupied by the DEM (not mandatory, but it may be useful if system RAM is limited)
del m

if d.data is not None:
    # create a SOFA instance and focus the input radargram
    f = SOFA(i, cc, dem_radius_profile, d, pars, n_processes=4, debug_mode=True)
    focused_rdr = f.focus()
    if focused_rdr is not None:
        envi.write(EDR_PDS_OUTPUT_FOC_FILENAME_BASE + "_ha-" + str(pars.frame_half_aperture) + "_s-" + str(
            pars.squint_angle), focused_rdr)

        # plot the focused radargram
        rp = RadargramPlot(focused_rdr, top_point=top_point, bottom_point=bottom_point, title="Radargram")
        rp.plot()

— Reply to this email directly, view it on GitHub https://github.com/adamoferro/sopa/issues/1#issuecomment-1107784117, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADG7O6P2OCLRKTBWXCK6XUDVGT4YTANCNFSM5TVX5FLA . You are receiving this because you commented.Message ID: @.***>

raypenper commented 2 years ago

The megt_s_128_1.img file is a topographic map of the south pole of Mars at a resolution of 128 pixels per degree from https://pds-geosciences.wustl.edu When I changed the input as megr_n_128.img radius file. It still did not work. now the error has become: image

adamoferro commented 2 years ago

Hello! The MOLA data you are using is not ok for SOPA. SOPA doesn't work with "POLAR" data, but only with MEGDR standard data. Moreover, the simple .img file should not be ok, as it's not an ENVI file.

I uploaded for you a MEGDR 128dpp mosaic of the whole Mars in ENVI format, here: https://drive.google.com/drive/folders/1_zX3GxDnBZChdMa6zkuyvZ6vBehyd_ML You must download both files and keep them in the same folder. It's about 2 Gbytes. I hope you have enough RAM to load it into memory when you run SOPA.

The error you posted seems to be related to the module "ray". It seems you have a different version wrt the one supported by SOPA. SOPA has been tested only with ray 0.7.3. I can't state if/how it works with other versions. You can either use the same supported version, or disable parallel processing by setting the parameters "n_processes" to 1. In the latter case SOPA wouldn't load ray, so that error should not appear anymore. However, it will probably be slower.

Hope this helps! Adamo

On Tue, Apr 26, 2022 at 7:12 PM raypenper @.***> wrote:

The megt_s_128_1.img file is a topographic map of the south pole of Mars at a resolution of 128 pixels per degree from https://pds-geosciences.wustl.edu When I changed the input as megr_n_128.img radius file. It still did not work. now the error has become: [image: image] https://user-images.githubusercontent.com/41855946/165355311-60db7b16-2d49-4afb-9b26-c5dddbefc509.png

— Reply to this email directly, view it on GitHub https://github.com/adamoferro/sopa/issues/1#issuecomment-1110048396, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADG7O6NMQKLK3JACETMFN4TVHAPW7ANCNFSM5TVX5FLA . You are receiving this because you commented.Message ID: @.***>

raypenper commented 2 years ago

Hi there! Thank you for the detailed explanation and sharing! It is of great help!

All the best, Peng

adamoferro commented 1 year ago

You are welcome! Let me know if you manage to make it work. Regards, Adamo

Il mar 3 mag 2022, 18:47 raypenper @.***> ha scritto:

Hi there! Thank you for the detailed explanation and sharing! It is of great help!

All the best, Peng

— Reply to this email directly, view it on GitHub https://github.com/adamoferro/sopa/issues/1#issuecomment-1116321975, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADG7O6OMVB5ZB2DY6HOEIJ3VIFKC3ANCNFSM5TVX5FLA . You are receiving this because you commented.Message ID: @.***>