steveberardi / starplot

✨ Star charts and maps in Python
https://starplot.dev
MIT License
17 stars 7 forks source link

Stereo north and south sometime produce images that are not circular #55

Closed bathoorn closed 3 months ago

bathoorn commented 4 months ago

I was trying to use stereo_north and stereo_south to create a Planispere i added some code to add a calendar circle. But using the code below produces a plot that is not circular

n = MapPlot(
    projection=Projection.STEREO_NORTH,
    lat=lat,
    lon=lon,
    dt=dt,
    ra_min=0,
    ra_max=24,
    dec_min=-4,
    dec_max=90,
    limiting_magnitude=5,
    style=style,
    resolution=1400,
)

setting dec_min to -40 does produce a circular plot. I have no clue where this is coming from

Here is an example image

11_planisphere_north_52N
steveberardi commented 4 months ago

Looks like you're running this on the v0.9.0 branch? I also get the distorted circle when running your code. The problem is with the old method for plotting constellation borders, cause if I remove the call to _plot_constellation_borders() in _init_plot and instead call the "new" method (plot_constellation_borders()) then I get a circle:

map-scratch-1

Everything on the v0.9.0 branch is still very much a work in progress :)

bathoorn commented 4 months ago

Well spotted :) I did not realise i was still on that branch.I first ran into an issue with plot_constellation_borders() that is why i switched but it seems to be working now.

Anyway currently i am trying to draw a calendar ring around the map so i can turn it into a planisphere using a laser cutter. My matplotlib skills are not that awesome yet so for now i added it in the svg in inkscape.

planisphere_north_52N

bathoorn commented 4 months ago

I will also have a look in the drawing times of the plot as it indeed draws all the stars and dso and then masks them out in the svg. So all the data is there in the file. Would be good to not draw it in the first place. This will decrease file size and render time.

steveberardi commented 4 months ago

super cool! I'd love to have Starplot be able to draw that calendar ring too. I've looked into some methods briefly, but it seems matplotlib doesn't have any built-in methods for drawing curved text. Still do-able, just might be a decent amount of work :)

Oh, I also looked into the plotting times for the Zenith Map plots, and it seems the DSO plotting is taking the most time (which makes sense cause DSOs are plotted one at a time). So, one simple thing we could do there to speed it up is switch the DSO plotting to plot by groups (i.e. plot all the open cluster markers with one scatter call cause they share the same style). This wouldn't help for DSOs that have a defined major axis though, or nebula polygons.

bathoorn commented 4 months ago

matplotlib also does a lot of clipping masks. I noticed this when importing an svg in lightburn (for laser engraving). So there are a lot more stars in the plot then are visible. Then i noticed this missing in the dso code:

        nearby_dsos = nearby_dsos.replace({np.nan: None}) # this line is there but the next one is missing
        nearby_dsos = nearby_dsos[
            (nearby_dsos["dec_degrees"] < self.dec_max)
            & (nearby_dsos["dec_degrees"] > self.dec_min)
        ]

Also needs one for ra_min and max but i think it is the same as for the star plot

For now all of this is a mess as i am still figuring out unions and intersections in shapely so i can cut lines that are partly in the plot. All if this reduces the drawing time and the size of the svg so it seems to be working.

bathoorn commented 4 months ago

I could share a branch in my fork so you can have a look if you are interested. But not all of it is usefull i think. As i was cutting some corners to have my planisphere plot come out nice. I need to do some refactoring to make it work on all projections.

bathoorn commented 4 months ago

Also found this link on plotting curved text https://stackoverflow.com/questions/19353576/curved-text-rendering-in-matplotlib