Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I delete leave structures that don't meet a criteria iteratively? #172

Open
seb-lopez opened this issue Feb 6, 2021 · 2 comments

Comments

@seb-lopez
Copy link

seb-lopez commented Feb 6, 2021

Hello so the issue I am having is that based off the information from the catalog from ppv_catalog I am setting criteria for the structures I want and the reasoning behind that is that once I run astrodendro and then with SCIMES I still get weather strips identified as structures and the show up in the final cube I want to use as a mask on ppv cubes for my data.

I have tried the following:

ar_ind = []

for i in range(len(AxRs)):
if (abs(PAs[i])>170) and (abs(PAs[i])<181):
ar_ind.append(i)

cat.remove_rows(ar_ind)

for j in range(len(d.leaves)):
for k in ar_ind:
if d.leaves[j].idx == k:
d.leaves.remove(d.leaves[j])

So in this case the criteria is based off position angle and the indices in the catalog are being matched with those in the leaves list and I try to remove the ones I don't want.

However it seems after I print out the result there is no change whatsoever and the structures I tried to remove via list.remove are still there.

Can I get any advice on fixing this? I don't recall seeing any remove function in astrodendro.structure.Structure so I opted to use the method above.

@e-koch
Copy link
Contributor

e-koch commented Feb 6, 2021

Hi @seb-lopez -- You should be able to use the Dendrogram.prune function here: https://github.com/dendrograms/astrodendro/blob/master/astrodendro/dendrogram.py#L513.

There is no built-in method to remove by position angle, so you will need to define your own criteria function and pass it to the is_independent keyword of prune. A couple of examples of criteria functions are here: https://github.com/dendrograms/astrodendro/blob/master/astrodendro/pruning.py#L108. There are a couple more here, too: https://github.com/dendrograms/astrodendro/pull/167/files#diff-d662f9d97218a42233417b75e9455f294cfce4506ea5c063d9bca056f00ff7d9R136.

@seb-lopez
Copy link
Author

Hi @e-koch, thanks for the reply and sorry for my late reply. I just picked this project back up after months of other things I needed to work on.

For pruning by PA I tried the following code:

` def param(ind):

     def result(structure, index=None, value=None):
        return structure.idx == ind
     return result  

d = Dendrogram.prune(d,is_independent=param(ar_ind)) `

Where ind is the list of indices that I want to filter out. I've tried this out before and my code just gets a 'Killed' output. Would I have to specify what part of the structure I am trying to prune such as structure.leaves or something like that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants