You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not quite sure where to put this but here's some simple code for getting the station lats and lons and plotting them on a map (provided by Basemap):
# Do:# $ conda install basemap# to get this - ideally create a new Conda environment for it.frommpl_toolkits.basemapimportBasemap#...for the MATH.importnumpyasnp#...for the plotting.importmatplotlib.pyplotasplt# Get the HiSPARC station information.fromsapphireimportHiSPARCStationsdefget_latlontext(cluster):
"""Create list of latitude, longitudes, and legend text for a cluster Make a list of locations for each of station and its detectors, for the stations the number is included. :param cluster: HiSPARCStations object. """lats= []
lons= []
forstationincluster.stations:
latitude, longitude, _=station.get_lla_coordinates()
lats.append(latitude)
lons.append(longitude)
fordetectorinstation.detectors:
latitude, longitude, _=detector.get_lla_coordinates()
lats.append(latitude)
lons.append(longitude)
returnlats, lons## List of the latitudes.lats= []
## List of the longitudes.lons= []
# Loop over thae stations (trial and error - FIXME!!!).foriinrange(100,200):
#lats, lons = get_latlontext(HiSPARCStations([102], force_stale=True))try:
mylats, mylons=get_latlontext(HiSPARCStations([i], force_stale=True))
exceptKeyError:
continue# skip if station number not found...# FIXME: just awful, I apologise.forj, latinenumerate(mylats):
lats.append(lat)
lons.append(mylons[j])
# Create a new figure.fig=plt.figure()
# Create the axes.ax=fig.add_axes([0.1,0.1,0.8,0.8])
# Setup a mercator map projection.m=Basemap(llcrnrlon=-20.,llcrnrlat=45.,urcrnrlon=20.,urcrnrlat=60.,\
rsphere=(6378137.00,6356752.3142),\
resolution='l',projection='merc',\
lat_0=40.,lon_0=-20.,lat_ts=20.)
# Draw the coastlines.m.drawcoastlines()
# Draw the continents.m.fillcontinents()
# Draw the parallels.m.drawparallels(np.arange(10,90,20),labels=[1,1,0,1])
# Draw the meridians.m.drawmeridians(np.arange(-180,180,30),labels=[1,1,0,1])
# Convert to x and y coordinates suitable for plotting.x,y=m(lons, lats)
# Plot the points.m.plot(x, y, 'bo', markersize=5)
# Set a title.ax.set_title('HiSPARC Stations')
# Show the plot!plt.show()
# Save the figure.fig.savefig("map.png")
It produces this:
Not amazing but at least I've got something out with my CernVM Sapphire. Thanks again for the Conda tip - it's brilliant!
The text was updated successfully, but these errors were encountered:
Not quite sure where to put this but here's some simple code for getting the station lats and lons and plotting them on a map (provided by Basemap):
It produces this:
Not amazing but at least I've got something out with my CernVM Sapphire. Thanks again for the Conda tip - it's brilliant!
The text was updated successfully, but these errors were encountered: