Skip to content

Commit

Permalink
compute mean bPerp, unclear what to do with this
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfore committed Jul 24, 2024
1 parent cbaa58c commit 89ef6c2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tools/bin/ariaTSsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,15 @@ def main():
# Track consistency of dimensions
ARIAtools.util.vrt.dim_check(ref_arr_record, prod_arr_record)

# Extract bPerp to json file
for product in standardproduct_info.products[1]:
bperp0 = osgeo.gdal.Open(
product['bPerpendicular'][0]).ReadAsArray().mean()
bperp1 = osgeo.gdal.Open(
product['bPerpendicular'][1]).ReadAsArray().mean()
LOGGER.info('Pair name: %s, bPerpendicular %s %s' % (
product['pair_name'], bperp0, bperp1))

# Extracting other layers, if specified
(layers, args.tropo_total, model_names) = ARIAtools.util.vrt.layerCheck(
standardproduct_info.products[1], args.layers, args.nc_version,
Expand Down

1 comment on commit 89ef6c2

@mgovorcin
Copy link
Collaborator

@mgovorcin mgovorcin commented on 89ef6c2 Jul 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexfore when skipping bPerp extraction and getting it directly from the ARIA GUNW product, you need to calculate mean of each product in the group and take then mean of that.
Below is the example of the function that you can use

def extract_bperp_dict_frame(aria_prod):
    mean_bperp = {}
    for prod in aria_prod:
        pair_name = prod['pair_name'][0]
        frame_mean_bperp = [osgeo.gdal.Open(frame).ReadAsArray().mean()
                            for frame in prod['bPerpendicular']]
        mean_bperp[pair_name] = float(np.mean(frame_mean_bperp))

    return mean_bperp 

Get the values

b_perp = extract_bperp_dict_frame(standardproduct_info.products[1])
# Save it to local dir
bperp_out = os.path.join(work_dir, 'perpendicularBaseline', 'bperp.json')
with open(bperp_out, "w") as outfile: 
              json.dump(b_perp, outfile)

and then you read this file in generate_stack line 271:

if os.path.exists(bperp_out):
    with open(bperp_out)) as f:
        b_perp = json.loads(f)
else:
    b_perp = extract_bperp_dict(domain_name, dlist)

Output example:

{'20211214_20211208': 13.323936462402344,
 '20211220_20211208': 54.31802749633789,
 '20211220_20211214': 40.99889373779297,
 '20220101_20211208': 19.83063507080078,
 '20220101_20211214': 0.9823713302612305,
 '20220101_20211220': -40.107322692871094,
 '20220113_20211214': -12.388989448547363,
 '20220113_20211220': -52.70809555053711,
 '20220113_20220101': -16.069971084594727,
 '20220125_20220101': -54.60516357421875,
 '20220125_20220113': -42.079322814941406,
 '20220206_20220101': -63.93281555175781,
 '20220206_20220113': -50.13213348388672,
 '20220206_20220125': -8.059051513671875,
 '20220218_20220113': 67.12799072265625,
 '20220218_20220125': 109.18669128417969,
 '20220218_20220206': 117.24237823486328,
 '20220302_20220125': 34.54039001464844,
 '20220302_20220206': 42.20716857910156,
 '20220302_20220218': -77.43914794921875,
 '20220314_20220206': 13.645223617553711,
 '20220314_20220218': -106.22195434570312,
 '20220314_20220302': -29.679933547973633,
 '20220326_20220218': -96.62528228759766,
 '20220326_20220302': -23.241485595703125,
 '20220326_20220314': 12.28775691986084}

Please sign in to comment.