Matty
Matty

Reputation: 63

Remove elements from string array

I have a header from a fits-file which I want to modify. Changing values is no problem using sxaddpar, but deleting them.

All the keys I want to delete are in a single string-array, and the ones I want to delete I find like this:

to_delete = ['BLANK*', 'HISTORY*', 'SOMECRAP*']
to_remove = []
n = N_ELEMENTS(to_delete)-1
for i=0, n do begin
     to_remove = [to_remove, WHERE(STRMATCH(header, to_delete[i], /FOLD_CASE) EQ 1)]
endfor

How do I get the result with the elements from header, that are not in to_remove?

Upvotes: 0

Views: 678

Answers (1)

mgalloy
mgalloy

Reputation: 2386

You want to get the complement of the indices in to_remove. See MG_COMPLEMENT. Make sure to get the latest version, as I had to add the ability to ignore the -1's inside to_remove.

Upvotes: 1

Related Questions