Scanline from scan_subindex of S5P products

Dear Sander,

I am sure that the reply to my question will be something very obvious, which right now eludes me.

For reasons I do not wish to bother you with, I would like to output the scanline from the operational S5P product. Harp merges scanline and ground_pixel as

scan_subindex description the scanline and pixel dimensions are collapsed into a temporal dimension; the index of the pixel within the scanline is computed as the index on the temporal dimension modulo the number of scanlines

and indeed, I can turn the ingested product index into the ground pixel with modulo, for e.g.

In [16]:product.index.data % 450
Out[16]: array([14, 15, 13, 14, 15, 16, 12, 13, 14, 15, 16, 12, 13, 14, 15, 16, 12,
13, 14, 15, 16, 12, 13, 14, 15, 16, 13, 14, 15], dtype=int32)

In [19]: product.scan_subindex.data
Out[19]: array([14, 15, 13, 14, 15, 16, 12, 13, 14, 15, 16, 12, 13, 14, 15, 16, 12,
13, 14, 15, 16, 12, 13, 14, 15, 16, 13, 14, 15], dtype=int16)

Is there a similar way to find out the original scanline? these should be just a few consecutive scanlines since they refer to a very small part of the orbit [some 20km around a location]

Many thanks,
MariLiza

Hey Sander,
Just to say I solved the issue, in a clearly non pythonc-way! :slight_smile:
pf = coda.open(infile)
scanline = coda.fetch(pf, ‘PRODUCT/scanline’)
pixel = coda.fetch(pf, ‘PRODUCT/ground_pixel’)
arr = np.zeros(len(pixel)len(scanline))
j=0
for i in range(0,len(scanline)len(pixel),len(pixel)):
# print((0
i+i),(0
i+i+450))
arr[(0i+i):(0i+i+len(pixel))] = scanline[j]
j=j+1

I then include it in a previously ingested product using harp and operations,
product.scanline = harp.Variable(arr[product.index.data], [“time”])

All well!
MariLiza

Maybe I misunderstand what you want, but isn’t the scanline just equal to product.index.data/450?

I would have thought so also, but I get non-integer replies, which confused me.

product.index.data/450
Out[75]:
array([2380.31111111, 2380.31333333, 2380.31555556, 2380.31777778,
2381.30666667, 2381.30888889, 2381.31111111, 2381.31333333,
2381.31555556, 2381.31777778, 2381.32 , 2382.30444444,
2382.30666667, 2382.30888889, 2382.31111111, 2382.31333333,
2382.31555556, 2382.31777778, 2382.32 , 2382.32222222,
2383.30444444, 2383.30666667, 2383.30888889, 2383.31111111,
2383.31333333, 2383.31555556, 2383.31777778, 2383.32 ,
2383.32222222, 2384.30444444, 2384.30666667, 2384.30888889,
2384.31111111, 2384.31333333, 2384.31555556, 2384.31777778,
2384.32 , 2384.32222222, 2385.30444444, 2385.30666667,
2385.30888889, 2385.31111111, 2385.31333333, 2385.31555556,
2385.31777778, 2385.32 , 2386.30666667, 2386.30888889,
2386.31111111, 2386.31333333, 2386.31555556, 2386.31777778])

You can use integer division by using the // operator. That
should give you the right scanline indices.

1 Like

Thanks Sander, my python skills need a lot more work it seems.
MariLiza

Hi Marliza,

just one question here, is 450 the number of total ground pixels or total scanlines in the product?

Thanks!

Best,
Serena

1 Like

Hi Serena, 450 is the total number of across dimension pixels within a single scanline.

1 Like

Hi Serena,
Sander beat me to it! You are think of the 450 as being the pixels roughly in the east-west dimension, and the scanlines [roughly 3000-3500 each time] in the north-south dimension in the S5P files.
Best wishes,
MariLiza

Thank you to both! :slightly_smiling_face:

1 Like