astro.services.skymap package

Submodules

astro.services.skymap.GMapQuery module

File GMapQuery.py Author WJ Vriend (wjvriend[AT]astro.rug.nl)

exception astro.services.skymap.GMapQuery.GMapError

Bases: Exception

class astro.services.skymap.GMapQuery.GMapFrameQueryThread(parent, *args, **kwargs)

Bases: common.config.ProfileThread.ProfileThread

class for querying and handling Frames in a seperate thread

index_frame_totals = {'CoaddedRegriddedFrame': 3, 'RawScienceFrame': 0, 'ReducedScienceFrame': 1, 'RegriddedFrame': 2, 'SourceList': 4}
make_frame(row, corners)

from the database row create a frame dict

make_frame_sky(row)

make a frame for the whole sky view

make_frames_dict(rs, grouped, line_color, fill_color)

make json dict structure for the frames

make_frames_sky_dict(sql_select, sql_from, sql_where, sql_groupedby, sql_orderby, args)

get the frame overview for the ‘whole’ sky

make_grouped_frame(row, corners)

From the database row create new frame dict or merge with existing frame dict The frames are grouped on the raw_fits_data attribute

sql_query_frames(sql_select, sql_from, sql_where, sql_groupedby, sql_orderby, args)

Generic query frames method

sql_query_selectors(sql_from, sql_where, args)

query the selectors instrument/filter/chip/date_obs/…

update_frame_dict(frame_cls_str, frame, frame_to_update)

update frame_to_update with info from frame

update_skymode_total(frame_update, frame_cls, frame_input=None, total=0)

update the total of cls in the sky mode frame dict also update line and fill color if frame type is ‘newer’

raw -> reduced -> regrid -> coadd -> sourcelist
class astro.services.skymap.GMapQuery.GMapFrameSql(parent)

Bases: object

class for generating sql for frames in GMap

get_coadd_sql(frame_cls)

get the sql to query CoaddedRegriddedFrames

get_frame_sky_sql(frame_cls)

return sql select statement for frame all sky mode

get_frame_sql(frame_cls)

get the sql to query RawScienceFrames, ReducedScienceFrames or RegriddedFrames

get_sql(frame_cls)

get the sql for the frame of class cls

get_sql_where_frames(frame_cls, selectors=True)

get the sql where statements for frames

class astro.services.skymap.GMapQuery.GMapQuery(args)

Bases: common.services.general.HtmlBase.HtmlBase

This class generates JSON files for GMap overlays

Instead of XML JSON is used :
smaller, faster to generate and faster to parse

Between the web service skymap and the backend (this code), JSON is used to transfer data. This is lighter and faster then xml.

This is the structure for frames: {

‘frames’ : {
frame_id1 : {
‘ra’ : [ra1, ra2, ra3, ra4], ‘dec’ : [dec1, dec2, dec3, dec4], ‘XXXFrame’ : <count of XXXFrame’s> # XXXFrame in [Raw, Reduced, Regrid, Coadd] ‘title’ : ‘title of the frame for markers’, ‘line_color’ : ‘#xxxxxx’, ‘fill_color’ : ‘#xxxxxx’, ‘fill_density’ : 0.05, ‘extra’ : [ … list with extra key,values … ]

}, frame_id2 : { … },

}, ‘stats’ : {

‘total_raw_frames’ : N, ‘total_coadd_frames’ : N, … ‘total_raw_objects’ : N, ‘total_coadd_objects’ : N, …

}, ‘lists’ : {

‘date_obs’ : […], ‘instruments’ : […], ‘filters’ : […], …

}, ‘conf’ : {

‘frame_marker_zoom’ : ‘[int] zoom level the marker should visible,

},

}

This is the structure for SourceLists: {

‘sourcelists’ : {
SLID1 : {
‘ra’ : [ra1, ra2, ra3, ra4], ‘dec’ : [dec1, dec2, dec3, dec4], ‘title’ : ‘title of the SourceList for markers’, ‘line_color’ : ‘#xxxxxx’, ‘fill_color’ : ‘#xxxxxx’, ‘fill_density’ : 0.05, ‘extra’ : [ … list with extra key,values … ] ie: frame_type, number_of_sources

}, SLID2 : { … },

}, ‘stats’ : {

‘total_sourcelists’ : N,

}, ‘lists’ : {

‘instruments’ : […], ‘filters’ : […], …

}, ‘conf’ : {

‘sourcelist_marker_zoom’ : ‘[int] zoom level the marker should visible,

},

}

This is the structure for Sources: {

‘sources’ : {
SID1 :
‘coord’ : (ra, dec), ‘title’ : ‘title of the source marker’, ‘extra’ : [ … list with extra key,values … ]

}, SID2 : { … },

}, ‘stats’ : {

‘total_sources’ : N, ‘centre’ : (ra, dec),

}, ‘lists’ : { }, ‘conf’ : {

‘source_marker_zoom’ : ‘[int] zoom level the marker should visible,

},

}

This is the structure in case of an error: {

‘error’ : <error msg>

}

corners is a bounding box with 4 corners in ra,dec space

dec_max

3——-2 | |

ra_max | | ra_min
0——-1
dec_min
abs_max_frames = 5000
abs_max_sources = 2000
fill_colors = {'coadd': '#0000FF', 'raw': '#FF0000', 'reduced': '#00FF00', 'regrid': '#FF8040', 'sl': '#FF00FF'}
frame_marker_zoom = 8
frame_marker_zoom_sky = 5
frame_types = {'coadd': 'CoaddedRegriddedFrame', 'raw': 'RawScienceFrame', 'reduced': 'ReducedScienceFrame', 'regrid': 'RegriddedFrame'}
getContentType()

set the content type to json

getHtml()

generate the json, and catch errors

get_empty_dict()

get an empty X type dict

get_frame_threads()

query for frames

get_sourcelists_thread()

return the thread for querying and handling sourcelists

get_sources_thread()

return the thread for querying and handling sources

handle_selectors(thread, result)

add unique selectors to result

line_colors = {'coadd': '#000077', 'raw': '#770000', 'reduced': '#007700', 'regrid': '#778040', 'sl': '#770077'}
max_zoom = 6
query_types = ('frames', 'sourcelists', 'sources')
runQueries()

run the queries and return result

selectors = {'filters': ('filter', 'tf.name'), 'instruments': ('instrument', 'ti.name'), 'objects': ('OBJECT', 't.OBJECT#'), 'obsdates': ('DATE_OBS', "to_char(t.DATE_OBS, 'yyyy-mm-dd') "), 'observers': ('OBSERVER', 't.OBSERVER')}
selectors_tables = {'filter': 'Filter', 'instrument': 'Instrument'}
sourcelist_marker_zoom = 8
sourcelist_marker_zoom_sky = 5
sources_zoom = 10
class astro.services.skymap.GMapQuery.GMapSourceListQueryThread(parent, *args, **kwargs)

Bases: common.config.ProfileThread.ProfileThread

Class for querying and handling SourceLists in separate thread

get_sourcelists()

query for sourcelists

get_sourcelists_sky()

get the sourcelists overview for the ‘whole’ sky

class astro.services.skymap.GMapQuery.GMapSourcesQueryThread(parent, *args, **kwargs)

Bases: common.config.ProfileThread.ProfileThread

Class for querying and handling Sources in separate thread

get_sources()

query for SourceList*sources of a specific SLID

class astro.services.skymap.GMapQuery.NumpyEncoder(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

Bases: json.encoder.JSONEncoder

SourceList attributes can be numpy type, those cannot be used in json.dumps, cast to json compatible value

default(obj)
astro.services.skymap.GMapQuery.database_select(caller, sql, args, log_result)

execute sql and log, if log_result log the result else log length of result

astro.services.skymap.HtmlGMap module

File HtmlGMap.py Author WJ Vriend (wjvriend@astro.rug.nl)

class astro.services.skymap.HtmlGMap.HtmlGMap(args)

Bases: common.services.general.HtmlBase.HtmlBase

This class generates Html files for GMap overlays

DEFAULT_DEC = 41.27
DEFAULT_RA = 10.68
DEFAULT_ZOOM = 7
URL_NAME = 'GMap'
getHtml()

generate the html form

classmethod get_url(server='skymap.astro-wise.org', project=None, full_url=True, ra=None, dec=None, zoom=None)

return an url for the given search_str

Module contents