SDOML / SDOMLv2

MIT License
8 stars 1 forks source link

Converting Stonyhurst coordinates to pixel values. #4

Open JulioHC00 opened 1 year ago

JulioHC00 commented 1 year ago

I'm trying to convert Stonyhurst coordinates into pixel values by using Sunpy. A simple example, assuming root is the SDOML s3://gov-nasa-hdrl-data1/contrib/fdl-sdoml/fdl-sdoml-v2/sdomlv2_hmi.zarr/ folder, is as follows (this is just plotting the stonyhurst coordinates which can later on be converted to pixel values with world_to_pixel)

import sunpy.map as smap
import matplotlib.pyplot as plt
from astropy.coordinates import SkyCoord
import astropy.units as u

data_x = root["2010"]["Bx"]
arr_x = da.from_zarr(data_x)

def get_header(data, index):
    headr = {keys: values[index] for keys, values in data.attrs.items()}
    return headr

example_img = arr_x[0]
example_header = get_header(data_x, 0)

fig = plt.figure()
ax = plt.subplot(projection=hmimap)

hmimap.plot(axes=ax)

stonyhurst_centre = SkyCoord(0 * u.deg, 0 * u.deg, frame="heliographic_stonyhurst")

ax.plot_coord(stonyhurst_centre, "x", color="white")

However, the centre in stonyhurst coordinates is not at the centre of the image. Is this expected? As I understand it, SDO images should have the stonyhurst centre in the centre of the image. Could this be a problem when reading the header information? Or is it a result of the processing that is applied to SDOML data.

PaulJWright commented 1 year ago

@kingbob8, maybe you're able to help here?

PaulJWright commented 1 year ago

If you're able to directly obtain a HMI image from JSOC, do you see the same thing for the same image?

JulioHC00 commented 1 year ago

This top one is from SDOML, the white cross is the (0,0) point in Stonyhurst coordinates

image

And this one I've obtained directly from JSOC using the hmi.B_720s series and the field segment, which I think is what is used for SDOML. It seems like the (0,0) point is in the same position so it's probably not something to do with SDOML but if anyone knows why the point shouldn't be at the centre I'd really appreciate some insights!

image

For completeness, this is what the hmi.M_720s magnetogram looks like. Same thin

image

PaulJWright commented 1 year ago

I believe it's most likely due to inclination that hasn't been corrected for. It should perhaps line up twice a year at (0,0)? I would suggest plotting the position as a function of time, and it should be ~ sinusoidal

JulioHC00 commented 1 year ago

I'll try to do that. Seems likely to be what happens, but I've never heard of such a thing with SDO and images in JHelioviewer seem to be centred, which leads me to believe it may be something to do with SunPy. I'll try to open an issue in their project because their chat isn't working and I'll comment back in case this is useful for people in the future.

Indeed, it does have a sinusoidal pattern over time in the y-direction

image