matthew-gaddes / ICASAR

An algorithm for robustly appling sICA to InSAR data
BSD 2-Clause "Simplified" License
36 stars 8 forks source link

pixel mask problem #2

Open zhabuxiacuncunzhang opened 1 year ago

zhabuxiacuncunzhang commented 1 year ago

Hello, I am doing some work about ICA and using my interferograms data. But there are something wrong before ICA.

ValueError: NumPy boolean array indexing assignment cannot assign 172558 input values to the 0 output values where the mask is true

My pixel mask is all True, because I masked them before.

image

Can you help me?

matthew-gaddes commented 1 year ago

Hi Xuesong Zhang,

Perhaps we are defining "mask" differently. ICASAR treats interferograms as 1D arrays (row or column vectors), then it has a 2D mask that is the shape of a 2D interferogram, but True for where there are no pixels (water, incoherent etc.). If the mask is all True in this case, there would be no pixels.

If you look in the first example, you can see what ICASAR expects a mask to be :+1:

Line 70 onwards: with open('synthetic_data.pkl', 'rb') as f: A_dc = pickle.load(f) # these are the time courses and are column vectors. They control the strength through time of each of the synthetic sources.
S_synth = pickle.load(f) # these are the synthetic (spatial) sources and are row vectors.
N_dc = pickle.load(f) # these are the noise for each interferogarm.
pixel_mask = pickle.load(f) # this is the same shape as an interferogram, True for pixels that are masked

A simple ax.matshow(pixel_mask) should show how masks look.

Let me know if that's not clear or you're still getting errors.

Matt

zhabuxiacuncunzhang commented 1 year ago

Hello Matt, Thank you for your reply. It's really helpful. I made a mistake in the definition of mask. In my opinion, True stands for reservation and False stands for mask. It seems that this is wrong. I modified my script and it seems to be working at present. The work you do is very meaningful.

Xuesong Zhang

zhabuxiacuncunzhang commented 1 year ago

Hello Matt, This problem doesn't seem so simple. When I set all the mask to False, the program is work, but when I set several points to True, this error appears again. I tested the demo data and scripts, which are correct, so I don't know where my program is wrong.

This is my mask image: image

and some mask data: image

Is this a problem with my data? Please tell me some way to fix it.

Thank you for your help!

matthew-gaddes commented 1 year ago

Hi again,

I need to write new documents for ICASAR, so sorry that you're having trouble getting it to work.

It is designed to run with a mask and pixels that were output by your time series software, and therefore not change at this step. If you have data for every pixel then the mask must be false for every pixel, so it's good that that works. If you have a mask you'd like to use (like in your picture), you must apply this to the data before you give it to ICASAR. That way, the number of True pixels in your mask will be the same as the number of pixels in your 1d interferograms (when you turn them to row or column vectors).

So, in brief, you can't just change the mask you give to ICASAR to change the pixels it uses. You must also change the data to only have a value where the mask is True, then give the new data and new mask to ICASAR.

Hopefully that helps? I'll include this in the docs when I write them.

Matt

On Thu, 6 Apr 2023, 08:40 Xuesong_Zhang, @.***> wrote:

Hello Matt, This problem doesn't seem so simple. When I set all the mask to False, the program is work, but when I set several points to True, this error appears again. I tested the demo data and scripts, which are correct, so I don't know where my program is wrong.

This is my mask data: [image: image] https://user-images.githubusercontent.com/23610937/230307531-9e933941-baf3-4a5d-a584-6150fff4bc90.png

and some data: [image: image] https://user-images.githubusercontent.com/23610937/230307702-7855707b-72d0-4213-a6ba-e609d84cd1f7.png

Is this a problem with my data? Please tell me some way to fix it.

Thank you for your help!

— Reply to this email directly, view it on GitHub https://github.com/matthew-gaddes/ICASAR/issues/2#issuecomment-1498625324, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQDES23UX6S5JM5Z7HP2WDW7ZXPRANCNFSM6AAAAAAWTZCLUY . You are receiving this because you commented.Message ID: @.***>

zhabuxiacuncunzhang commented 1 year ago

Hello,

Do you mean that I need to set the pixels that have no data in the interferogram to True? At the same time, the other pixels keep the value? I'm sorry. I'm still not sure how this works.

The number of pixels of the interferogram I set is the same as that of mask. Each interferogram is a row vector, while mask is a two-dimensional matrix.

I checked the demo data, and all the pixels have values.

Or, the interferograms retains only pixels in mask that are set to False?

This is very interesting.

Xuesong Zhang