ACHMartin / seastar_project

4 stars 0 forks source link

Data variables for the "mid" antenna which have been created (Slave, ...) in order to merge the beams are not set to NaN #221

Closed ACHMartin closed 1 year ago

ACHMartin commented 1 year ago

For the "mid" antenna, we expect the Interferogram to be constantly NaN.

Using the code below (inspired from OSCAR_star_pattern_v1.ipynb notebooks), the interferogram is not a constant NaN but only noisy dsl1['Track_13'].sel(Antenna='Mid').Interferogram.plot() download

Looking further, we have: dsl1['Track_13'].sel(Antenna='Mid').SigmaImageSingleLookRealPartSlave.sel(CrossRange=0) which has proper values and is not set to NaN as expected.

I assume the issue is in level1/fill_missing_variables particularly line 46 ds_diff.where(ds_diff == np.nan, other=np.nan) In my mind .where does not change anything to the dataset. So, in my view it does nothing and we just copy the field from "Fore"

After correcting this, need to check the Interferogram goes to NaN as well and that xarray is not playing tricks.

On a side notes some data are set to -999. We need to put it to NaN. Probably using a new function.

# Data load and pre-processing
version = 'v20221104'

oscar_path = "../DATA/OSCAR/" + version + "/matlab-pre-processed/"

file_time_triplets = ss.utils.tools.find_file_triplets(oscar_path)

print('OSCAR L1 processing - version ' + version)
print('-------------------')
print('File path :', oscar_path)
print('-------------------')
for i in range(len(file_time_triplets)):
    print('File index :', i, ',', 'Aquisition time :', file_time_triplets[i][0], ',', 'File list indices :', file_time_triplets[i][1])

# Match tracks in the star pattern from track names and times in the DAR_v6.0 to file aquisition times
star_pattern_tracks={
    'Track_L1' : 0,
    'Track_1a' : 1,
    'Track_2a' : 2,
    'Track_1b' : 3,
    'Track_11' : 4,
    'Track_12' : 5,
    'Track_13' : 6,
    'Track_14' : 7,
    'Track_15' : 8,
    'Track_16' : 9,
    'Track_17' : 10,
    'Track_18' : 11}

# Compute L1C - Sigma0 + RVL
dsl1 = dict()
for track in star_pattern_tracks.keys(): # Loop through star pattern tracks
    file_index = star_pattern_tracks[track]
    ds = ss.utils.readers.load_OSCAR_data(oscar_path, file_time_triplets[file_index][1])
    antenna_ident = ss.utils.tools.identify_antenna_location_from_filename(oscar_path, file_time_triplets[file_index][1])
    ds = ss.oscar.level1.fill_missing_variables(ds, antenna_ident)
    print('Processing file index',file_index)
    # L1 processing
    for i in list(ds.keys()):
        ds[i] = ss.oscar.level1.check_antenna_polarization(ds[i])
        ds[i] = ss.oscar.level1.compute_multilooking_Master_Slave(ds[i], window=7)
#         ds[i]['Baseline'] = ss.oscar.level1.compute_antenna_baseline(0.2)
        ds[i] = ss.oscar.level1.compute_antenna_azimuth_direction(ds[i], antenna=antenna_ident[list(ds.keys()).index(i)])
        ds[i] = ss.oscar.level1.compute_time_lag_Master_Slave(ds[i], options='from_SAR_time')
        ds[i] = ss.oscar.level1.compute_radial_surface_velocity(ds[i])
    #Build L1 dataset
    dsl1[track] = ss.oscar.level1.merge_beams(ds, antenna_ident)
DavidMcCann-NOC commented 1 year ago

Closed with #224