In [17]:
import warnings
warnings.simplefilter('ignore')

Marvin Results

This tutorial explores some basics of how to handle results of your Marvin Query. Much of this information can also be found in the Marvin Results documentation.

Table of Contents:

Performing a Query

Our first step is to generate a query. Let's perform a simple metadata query to look for all galaxies with a redshift < 0.1. Let's also return the absolute magnitude g-r color and the Elliptical Petrosian half-light radius. This step assumes familiarity with Marvin Queries. To learn how to write queries, please see the Marvin Query documentation or the Marvin Query Tutorial.


In [1]:
# set up and run the query
from marvin.tools.query import Query
q = Query(search_filter='nsa.z < 0.1', return_params=['absmag_g_r', 'nsa.elpetro_th50_r'])
r = q.run()


INFO: No release version set. Setting default to DR15
/Users/Brian/anaconda2/envs/marvindev/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  return f(*args, **kwds)
/Users/Brian/anaconda2/envs/marvindev/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  return f(*args, **kwds)
/Users/Brian/anaconda2/envs/marvindev/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  return f(*args, **kwds)
/Users/Brian/anaconda2/envs/marvindev/lib/python3.5/site-packages/marvin/tools/query.py:236: MarvinUserWarning: No local database found. Cannot perform queries.
  warnings.warn('No local database found. Cannot perform queries.', MarvinUserWarning)

In [2]:
# repr the results
r


Out[2]:
Marvin Results(query=nsa.z < 0.1, totalcount=4275, count=100, mode=remote)

Our query runs and indicates a total count of 4275 results. By default, queries that return more than 1000 rows will be automatically paginated into sets (or chunks) of 100 rows, indicated by count=100. The number of rows queries return can be changed using the limit keyword argument to Qeuery. The results are stored in the results attribute.


In [3]:
# look at the results
r.results


Out[3]:
<ResultSet(set=1.0/43, index=0:100, count_in_set=100, total=4275)>
[ResultRow(mangaid='1-109056', plateifu='8077-6103', elpetro_absmag_g_r=1.11703872680664, elpetro_th50_r=3.709, z=0.0473019),
 ResultRow(mangaid='1-109073', plateifu='8078-12704', elpetro_absmag_g_r=1.05978775024414, elpetro_th50_r=7.54724, z=0.0435882),
 ResultRow(mangaid='1-109081', plateifu='8077-12705', elpetro_absmag_g_r=1.23031806945801, elpetro_th50_r=9.60665, z=0.0438592),
 ResultRow(mangaid='1-109112', plateifu='8078-1901', elpetro_absmag_g_r=1.5319881439209, elpetro_th50_r=2.25541, z=0.0249702),
 ResultRow(mangaid='1-109152', plateifu='8154-12702', elpetro_absmag_g_r=1.5439453125, elpetro_th50_r=16.1263, z=0.0281736),
 ResultRow(mangaid='1-109167', plateifu='8078-1902', elpetro_absmag_g_r=1.65657424926758, elpetro_th50_r=1.91322, z=0.0246344),
 ResultRow(mangaid='1-109234', plateifu='9193-1901', elpetro_absmag_g_r=1.52570343017578, elpetro_th50_r=2.16528, z=0.0409309),
 ResultRow(mangaid='1-109244', plateifu='8080-12702', elpetro_absmag_g_r=1.52271270751953, elpetro_th50_r=15.379, z=0.0267911),
 ResultRow(mangaid='1-109250', plateifu='8080-1902', elpetro_absmag_g_r=0.780342102050781, elpetro_th50_r=2.15977, z=0.0383731),
 ResultRow(mangaid='1-109270', plateifu='9193-12703', elpetro_absmag_g_r=1.28193092346191, elpetro_th50_r=2.7424, z=0.0252266),
 ResultRow(mangaid='1-109284', plateifu='8080-6103', elpetro_absmag_g_r=1.13128662109375, elpetro_th50_r=3.61366, z=0.0686101),
 ResultRow(mangaid='1-109356', plateifu='8081-3703', elpetro_absmag_g_r=1.01610565185547, elpetro_th50_r=4.40028, z=0.0241782),
 ResultRow(mangaid='1-109378', plateifu='8084-12703', elpetro_absmag_g_r=1.15368461608887, elpetro_th50_r=9.6417, z=0.0391104),
 ResultRow(mangaid='1-109392', plateifu='8085-6101', elpetro_absmag_g_r=1.57899284362793, elpetro_th50_r=6.78671, z=0.0514803),
 ResultRow(mangaid='1-109394', plateifu='8082-9102', elpetro_absmag_g_r=1.26038932800293, elpetro_th50_r=7.17137, z=0.0361073),
 ResultRow(mangaid='1-109428', plateifu='8155-3704', elpetro_absmag_g_r=1.65565872192383, elpetro_th50_r=1.6106, z=0.0476594),
 ResultRow(mangaid='1-109521', plateifu='8156-6101', elpetro_absmag_g_r=1.79952621459961, elpetro_th50_r=5.32495, z=0.0490484),
 ResultRow(mangaid='1-113208', plateifu='8618-3701', elpetro_absmag_g_r=1.48788070678711, elpetro_th50_r=2.7162, z=0.0699044),
 ResultRow(mangaid='1-113219', plateifu='7815-9102', elpetro_absmag_g_r=0.543312072753906, elpetro_th50_r=5.15853, z=0.0408897),
 ResultRow(mangaid='1-113242', plateifu='7972-6101', elpetro_absmag_g_r=1.90381813049316, elpetro_th50_r=6.17146, z=0.0437197),
 ResultRow(mangaid='1-113265', plateifu='7972-12703', elpetro_absmag_g_r=1.04117393493652, elpetro_th50_r=8.04141, z=0.0437398),
 ResultRow(mangaid='1-113315', plateifu='7972-3702', elpetro_absmag_g_r=1.66540908813477, elpetro_th50_r=3.02008, z=0.0622162),
 ResultRow(mangaid='1-113322', plateifu='7972-12701', elpetro_absmag_g_r=2.22256088256836, elpetro_th50_r=6.59968, z=0.0431628),
 ResultRow(mangaid='1-113343', plateifu='7972-1901', elpetro_absmag_g_r=1.6228084564209, elpetro_th50_r=1.47839, z=0.0433949),
 ResultRow(mangaid='1-113346', plateifu='7972-12702', elpetro_absmag_g_r=0.943971633911133, elpetro_th50_r=7.12185, z=0.0431389),
 ResultRow(mangaid='1-113368', plateifu='7972-6103', elpetro_absmag_g_r=1.61076927185059, elpetro_th50_r=5.52075, z=0.0431534),
 ResultRow(mangaid='1-113375', plateifu='7972-12704', elpetro_absmag_g_r=0.757579803466797, elpetro_th50_r=8.96766, z=0.028215),
 ResultRow(mangaid='1-113375', plateifu='7815-9101', elpetro_absmag_g_r=0.757579803466797, elpetro_th50_r=8.96766, z=0.028215),
 ResultRow(mangaid='1-113379', plateifu='7972-3701', elpetro_absmag_g_r=1.09770011901855, elpetro_th50_r=6.08388, z=0.0171611),
 ResultRow(mangaid='1-113379', plateifu='7815-6101', elpetro_absmag_g_r=1.09770011901855, elpetro_th50_r=6.08388, z=0.0171611),
 ResultRow(mangaid='1-113403', plateifu='7815-12703', elpetro_absmag_g_r=0.745466232299805, elpetro_th50_r=4.26406, z=0.0715126),
 ResultRow(mangaid='1-113404', plateifu='7972-6104', elpetro_absmag_g_r=1.0419807434082, elpetro_th50_r=3.55168, z=0.0422713),
 ResultRow(mangaid='1-113405', plateifu='7972-3704', elpetro_absmag_g_r=1.27382469177246, elpetro_th50_r=2.43736, z=0.0424723),
 ResultRow(mangaid='1-113418', plateifu='7815-12704', elpetro_absmag_g_r=1.44098854064941, elpetro_th50_r=7.31411, z=0.0430806),
 ResultRow(mangaid='1-113469', plateifu='7972-12705', elpetro_absmag_g_r=0.847789764404297, elpetro_th50_r=6.08098, z=0.0394617),
 ResultRow(mangaid='1-113469', plateifu='7815-12702', elpetro_absmag_g_r=0.847789764404297, elpetro_th50_r=6.08098, z=0.0394617),
 ResultRow(mangaid='1-113518', plateifu='7972-6102', elpetro_absmag_g_r=0.380338668823242, elpetro_th50_r=6.41199, z=0.0299975),
 ResultRow(mangaid='1-113520', plateifu='7815-1901', elpetro_absmag_g_r=1.7510347366333, elpetro_th50_r=2.98524, z=0.0167652),
 ResultRow(mangaid='1-113525', plateifu='8618-6103', elpetro_absmag_g_r=1.57906627655029, elpetro_th50_r=7.97363, z=0.0169457),
 ResultRow(mangaid='1-113525', plateifu='7815-1902', elpetro_absmag_g_r=1.57906627655029, elpetro_th50_r=7.97363, z=0.0169457),
 ResultRow(mangaid='1-113525', plateifu='7972-9102', elpetro_absmag_g_r=1.57906627655029, elpetro_th50_r=7.97363, z=0.0169457),
 ResultRow(mangaid='1-113539', plateifu='8618-12701', elpetro_absmag_g_r=1.26716613769531, elpetro_th50_r=16.6994, z=0.0177002),
 ResultRow(mangaid='1-113540', plateifu='7815-3702', elpetro_absmag_g_r=0.952407836914062, elpetro_th50_r=3.77495, z=0.0293823),
 ResultRow(mangaid='1-113551', plateifu='7972-3703', elpetro_absmag_g_r=1.46421432495117, elpetro_th50_r=2.83342, z=0.0588507),
 ResultRow(mangaid='1-113567', plateifu='7815-12701', elpetro_absmag_g_r=1.41732978820801, elpetro_th50_r=9.66008, z=0.0167432),
 ResultRow(mangaid='1-113567', plateifu='8618-1902', elpetro_absmag_g_r=1.41732978820801, elpetro_th50_r=9.66008, z=0.0167432),
 ResultRow(mangaid='1-113585', plateifu='7815-3703', elpetro_absmag_g_r=1.68158912658691, elpetro_th50_r=4.03009, z=0.070276),
 ResultRow(mangaid='1-113587', plateifu='8618-12704', elpetro_absmag_g_r=1.02355575561523, elpetro_th50_r=5.08098, z=0.0704926),
 ResultRow(mangaid='1-113647', plateifu='8618-6104', elpetro_absmag_g_r=1.78754997253418, elpetro_th50_r=3.97352, z=0.0738563),
 ResultRow(mangaid='1-113651', plateifu='7815-3704', elpetro_absmag_g_r=1.4986743927002, elpetro_th50_r=2.96539, z=0.0708847),
 ResultRow(mangaid='1-113654', plateifu='8618-9102', elpetro_absmag_g_r=1.10831832885742, elpetro_th50_r=4.88881, z=0.0430694),
 ResultRow(mangaid='1-113663', plateifu='8618-3703', elpetro_absmag_g_r=2.80322933197021, elpetro_th50_r=3.05035, z=0.0316328),
 ResultRow(mangaid='1-113672', plateifu='8618-3704', elpetro_absmag_g_r=1.25676536560059, elpetro_th50_r=2.30303, z=0.0702278),
 ResultRow(mangaid='1-113698', plateifu='8618-1901', elpetro_absmag_g_r=0.995195388793945, elpetro_th50_r=3.06745, z=0.0167445),
 ResultRow(mangaid='1-113700', plateifu='8618-12703', elpetro_absmag_g_r=0.61408805847168, elpetro_th50_r=4.6722, z=0.0378372),
 ResultRow(mangaid='1-113712', plateifu='7815-6104', elpetro_absmag_g_r=0.69244384765625, elpetro_th50_r=4.57927, z=0.0806967),
 ResultRow(mangaid='1-114073', plateifu='7975-12705', elpetro_absmag_g_r=0.751516342163086, elpetro_th50_r=8.94859, z=0.0402895),
 ResultRow(mangaid='1-114082', plateifu='7975-3701', elpetro_absmag_g_r=1.44381332397461, elpetro_th50_r=4.73158, z=0.0402683),
 ResultRow(mangaid='1-114121', plateifu='7975-12701', elpetro_absmag_g_r=1.43171119689941, elpetro_th50_r=6.238, z=0.0879313),
 ResultRow(mangaid='1-114128', plateifu='7975-6101', elpetro_absmag_g_r=1.86342239379883, elpetro_th50_r=3.28624, z=0.077875),
 ResultRow(mangaid='1-114129', plateifu='7975-12702', elpetro_absmag_g_r=2.19032287597656, elpetro_th50_r=10.6624, z=0.0774097),
 ResultRow(mangaid='1-114145', plateifu='7975-6102', elpetro_absmag_g_r=1.41496467590332, elpetro_th50_r=6.64386, z=0.0341885),
 ResultRow(mangaid='1-114171', plateifu='7975-3702', elpetro_absmag_g_r=1.70641708374023, elpetro_th50_r=4.32828, z=0.0881405),
 ResultRow(mangaid='1-114303', plateifu='7975-1901', elpetro_absmag_g_r=0.658689498901367, elpetro_th50_r=9.02474, z=0.0220107),
 ResultRow(mangaid='1-114306', plateifu='7975-9101', elpetro_absmag_g_r=0.99525260925293, elpetro_th50_r=7.50072, z=0.0636505),
 ResultRow(mangaid='1-114325', plateifu='7975-12703', elpetro_absmag_g_r=1.34337997436523, elpetro_th50_r=15.3995, z=0.0288791),
 ResultRow(mangaid='1-114334', plateifu='7975-1902', elpetro_absmag_g_r=1.43183898925781, elpetro_th50_r=3.08396, z=0.0222473),
 ResultRow(mangaid='1-114454', plateifu='7975-12704', elpetro_absmag_g_r=1.29723358154297, elpetro_th50_r=5.00931, z=0.0888606),
 ResultRow(mangaid='1-114465', plateifu='7975-6104', elpetro_absmag_g_r=1.21394157409668, elpetro_th50_r=4.04488, z=0.0788547),
 ResultRow(mangaid='1-114500', plateifu='7975-9102', elpetro_absmag_g_r=1.14164924621582, elpetro_th50_r=7.54684, z=0.0220849),
 ResultRow(mangaid='1-114502', plateifu='7975-6103', elpetro_absmag_g_r=1.4673023223877, elpetro_th50_r=3.43077, z=0.0798058),
 ResultRow(mangaid='1-114532', plateifu='7975-3703', elpetro_absmag_g_r=1.73165702819824, elpetro_th50_r=2.77167, z=0.0902261),
 ResultRow(mangaid='1-114928', plateifu='7977-3702', elpetro_absmag_g_r=1.65719413757324, elpetro_th50_r=4.63049, z=0.0273478),
 ResultRow(mangaid='1-114955', plateifu='7977-12701', elpetro_absmag_g_r=1.01249313354492, elpetro_th50_r=5.03401, z=0.0922799),
 ResultRow(mangaid='1-114956', plateifu='7977-3704', elpetro_absmag_g_r=1.3456974029541, elpetro_th50_r=3.93806, z=0.0270248),
 ResultRow(mangaid='1-114980', plateifu='7977-9102', elpetro_absmag_g_r=1.14808464050293, elpetro_th50_r=4.93319, z=0.0630915),
 ResultRow(mangaid='1-114998', plateifu='7977-6102', elpetro_absmag_g_r=2.77035713195801, elpetro_th50_r=6.30899, z=0.0614042),
 ResultRow(mangaid='1-115062', plateifu='7977-1901', elpetro_absmag_g_r=1.65952682495117, elpetro_th50_r=1.29971, z=0.0260569),
 ResultRow(mangaid='1-115085', plateifu='7977-6103', elpetro_absmag_g_r=0.912630081176758, elpetro_th50_r=4.95689, z=0.0349304),
 ResultRow(mangaid='1-115097', plateifu='7977-3701', elpetro_absmag_g_r=1.49947357177734, elpetro_th50_r=4.65282, z=0.0274473),
 ResultRow(mangaid='1-115128', plateifu='7977-1902', elpetro_absmag_g_r=1.1044979095459, elpetro_th50_r=7.78621, z=0.0358116),
 ResultRow(mangaid='1-115162', plateifu='7977-12703', elpetro_absmag_g_r=1.13131713867188, elpetro_th50_r=7.3267, z=0.0738627),
 ResultRow(mangaid='1-115320', plateifu='7977-3703', elpetro_absmag_g_r=0.99519157409668, elpetro_th50_r=4.72487, z=0.0275274),
 ResultRow(mangaid='1-120935', plateifu='8144-12703', elpetro_absmag_g_r=1.19215965270996, elpetro_th50_r=8.77348, z=0.0389089),
 ResultRow(mangaid='1-120941', plateifu='8144-9101', elpetro_absmag_g_r=1.37554359436035, elpetro_th50_r=7.13642, z=0.0157875),
 ResultRow(mangaid='1-120943', plateifu='8144-6102', elpetro_absmag_g_r=1.49009323120117, elpetro_th50_r=8.04322, z=0.0393096),
 ResultRow(mangaid='1-120955', plateifu='8144-12702', elpetro_absmag_g_r=1.05715751647949, elpetro_th50_r=8.80421, z=0.0512278),
 ResultRow(mangaid='1-120967', plateifu='8144-12704', elpetro_absmag_g_r=1.39360427856445, elpetro_th50_r=5.12678, z=0.0889617),
 ResultRow(mangaid='1-121023', plateifu='8144-6103', elpetro_absmag_g_r=1.77910804748535, elpetro_th50_r=3.76035, z=0.0617402),
 ResultRow(mangaid='1-121035', plateifu='8144-1901', elpetro_absmag_g_r=1.74846458435059, elpetro_th50_r=2.75435, z=0.0268051),
 ResultRow(mangaid='1-121075', plateifu='8144-3702', elpetro_absmag_g_r=1.42728805541992, elpetro_th50_r=2.65939, z=0.0978535),
 ResultRow(mangaid='1-121151', plateifu='8139-12701', elpetro_absmag_g_r=0.917177200317383, elpetro_th50_r=9.73124, z=0.0155876),
 ResultRow(mangaid='1-121202', plateifu='8139-1902', elpetro_absmag_g_r=1.09575843811035, elpetro_th50_r=2.09932, z=0.0406385),
 ResultRow(mangaid='1-121206', plateifu='8139-9101', elpetro_absmag_g_r=0.632560729980469, elpetro_th50_r=8.30522, z=0.0191816),
 ResultRow(mangaid='1-121209', plateifu='8139-6101', elpetro_absmag_g_r=1.92057991027832, elpetro_th50_r=5.64209, z=0.027711),
 ResultRow(mangaid='1-121218', plateifu='8139-3703', elpetro_absmag_g_r=0.984956741333008, elpetro_th50_r=7.58118, z=0.0440361),
 ResultRow(mangaid='1-121235', plateifu='8936-3702', elpetro_absmag_g_r=1.61528015136719, elpetro_th50_r=3.35647, z=0.0609332),
 ResultRow(mangaid='1-121236', plateifu='8139-6104', elpetro_absmag_g_r=1.68639945983887, elpetro_th50_r=7.48554, z=0.0607858),
 ResultRow(mangaid='1-121277', plateifu='8977-6101', elpetro_absmag_g_r=2.23527336120605, elpetro_th50_r=3.7656, z=0.0541615),
 ResultRow(mangaid='1-121330', plateifu='8977-12702', elpetro_absmag_g_r=0.697284698486328, elpetro_th50_r=9.80444, z=0.0174976)]

A ResultSet contains a list of tuple rows with some default parameters like mangaid and plateifu, plus any parameters used in the Query search_filter or requested with the return_params keyword. The redshift, g-r color, and half-light radius has been returned. We can look at all the columns available using the columns attribute.


In [4]:
# look at the columns returned by your results
r.columns


Out[4]:
<ParameterGroup name=Columns, n_parameters=5>
 [<QueryParameter full=cube.mangaid, name=mangaid, short=mangaid, remote=mangaid, display=Manga-ID>,
 <QueryParameter full=cube.plateifu, name=plateifu, short=plateifu, remote=plateifu, display=Plate-IFU>,
 <QueryParameter full=nsa.elpetro_absmag_g_r, name=elpetro_absmag_g_r, short=absmag_g_r, remote=elpetro_absmag_g_r, display=Absmag g-r>,
 <QueryParameter full=nsa.elpetro_th50_r, name=elpetro_th50_r, short=th50_r, remote=elpetro_th50_r, display=r-band half-light radius>,
 <QueryParameter full=nsa.z, name=z, short=z, remote=z, display=Redshift>]

Retrieving Results

There are several options for handling paginated results. To page through the sets of results without extending the results, use getNext and getPrevious. These methods simply page through.


In [5]:
# get the next set of results
n = r.getNext()


INFO: Retrieving next 100, from 100 to 200

In [6]:
# look at page 2
r.results


Out[6]:
<ResultSet(set=2.0/43, index=100:200, count_in_set=100, total=4275)>
[ResultRow(mangaid='1-121334', plateifu='8977-1902', elpetro_absmag_g_r=1.6729907989502, elpetro_th50_r=2.03886, z=0.0417555),
 ResultRow(mangaid='1-121375', plateifu='8977-3701', elpetro_absmag_g_r=1.73355865478516, elpetro_th50_r=2.59914, z=0.0828189),
 ResultRow(mangaid='1-121387', plateifu='8977-1901', elpetro_absmag_g_r=1.38675498962402, elpetro_th50_r=1.97636, z=0.0281629),
 ResultRow(mangaid='1-121413', plateifu='8977-12704', elpetro_absmag_g_r=0.746274948120117, elpetro_th50_r=8.3731, z=0.0158709),
 ResultRow(mangaid='1-121486', plateifu='8717-3704', elpetro_absmag_g_r=1.18856620788574, elpetro_th50_r=5.81742, z=0.0290077),
 ResultRow(mangaid='1-121523', plateifu='8977-12703', elpetro_absmag_g_r=2.02036094665527, elpetro_th50_r=5.31518, z=0.0752425),
 ResultRow(mangaid='1-121598', plateifu='8717-9102', elpetro_absmag_g_r=2.1969108581543, elpetro_th50_r=8.24715, z=0.0714115),
 ResultRow(mangaid='1-121607', plateifu='9485-1902', elpetro_absmag_g_r=1.71369934082031, elpetro_th50_r=3.44897, z=0.0405107),
 ResultRow(mangaid='1-121612', plateifu='9485-12702', elpetro_absmag_g_r=0.873281478881836, elpetro_th50_r=11.1178, z=0.0187191),
 ResultRow(mangaid='1-121697', plateifu='8717-6101', elpetro_absmag_g_r=1.64321327209473, elpetro_th50_r=3.93459, z=0.0456332),
 ResultRow(mangaid='1-121735', plateifu='8717-3703', elpetro_absmag_g_r=0.967935562133789, elpetro_th50_r=2.76035, z=0.0457813),
 ResultRow(mangaid='1-121773', plateifu='8717-12703', elpetro_absmag_g_r=0.82383918762207, elpetro_th50_r=12.1638, z=0.019982),
 ResultRow(mangaid='1-121784', plateifu='9181-3701', elpetro_absmag_g_r=1.23087501525879, elpetro_th50_r=2.91024, z=0.0402774),
 ResultRow(mangaid='1-121789', plateifu='9485-3701', elpetro_absmag_g_r=1.45931434631348, elpetro_th50_r=2.52096, z=0.0392324),
 ResultRow(mangaid='1-121803', plateifu='9181-1901', elpetro_absmag_g_r=1.66340065002441, elpetro_th50_r=2.15493, z=0.0408411),
 ResultRow(mangaid='1-121837', plateifu='9485-3702', elpetro_absmag_g_r=1.32039070129395, elpetro_th50_r=3.10665, z=0.0415041),
 ResultRow(mangaid='1-121851', plateifu='9485-6101', elpetro_absmag_g_r=1.6701717376709, elpetro_th50_r=5.74633, z=0.0719923),
 ResultRow(mangaid='1-121871', plateifu='9485-3703', elpetro_absmag_g_r=1.15477180480957, elpetro_th50_r=2.89156, z=0.0441646),
 ResultRow(mangaid='1-121911', plateifu='9183-12701', elpetro_absmag_g_r=1.38198661804199, elpetro_th50_r=2.09971, z=0.0211728),
 ResultRow(mangaid='1-121936', plateifu='9485-12703', elpetro_absmag_g_r=1.10766410827637, elpetro_th50_r=9.05546, z=0.0218013),
 ResultRow(mangaid='1-121947', plateifu='9485-6102', elpetro_absmag_g_r=1.85177803039551, elpetro_th50_r=4.76834, z=0.0891167),
 ResultRow(mangaid='1-121973', plateifu='9485-6104', elpetro_absmag_g_r=1.4388542175293, elpetro_th50_r=4.30801, z=0.0328443),
 ResultRow(mangaid='1-121992', plateifu='9183-1902', elpetro_absmag_g_r=1.55809211730957, elpetro_th50_r=1.70253, z=0.0280217),
 ResultRow(mangaid='1-121994', plateifu='9485-9102', elpetro_absmag_g_r=0.971985816955566, elpetro_th50_r=7.91071, z=0.0188169),
 ResultRow(mangaid='1-122002', plateifu='9485-1901', elpetro_absmag_g_r=1.04083061218262, elpetro_th50_r=2.24397, z=0.0712221),
 ResultRow(mangaid='1-122044', plateifu='9181-9102', elpetro_absmag_g_r=1.43736457824707, elpetro_th50_r=4.62257, z=0.0394439),
 ResultRow(mangaid='1-122054', plateifu='9485-12704', elpetro_absmag_g_r=1.55994606018066, elpetro_th50_r=1.83135, z=0.0422109),
 ResultRow(mangaid='1-122057', plateifu='9181-1902', elpetro_absmag_g_r=1.33530044555664, elpetro_th50_r=1.8542, z=0.0399474),
 ResultRow(mangaid='1-122059', plateifu='9183-12704', elpetro_absmag_g_r=1.40407371520996, elpetro_th50_r=8.17737, z=0.0762452),
 ResultRow(mangaid='1-122067', plateifu='9181-6104', elpetro_absmag_g_r=0.855253219604492, elpetro_th50_r=6.30572, z=0.0233687),
 ResultRow(mangaid='1-122088', plateifu='9486-12701', elpetro_absmag_g_r=0.916702270507812, elpetro_th50_r=23.9432, z=0.041528),
 ResultRow(mangaid='1-122094', plateifu='9183-9101', elpetro_absmag_g_r=1.50480842590332, elpetro_th50_r=7.58261, z=0.0355189),
 ResultRow(mangaid='1-122119', plateifu='9183-9102', elpetro_absmag_g_r=0.64360237121582, elpetro_th50_r=6.84965, z=0.0223205),
 ResultRow(mangaid='1-122141', plateifu='9183-3704', elpetro_absmag_g_r=1.48015403747559, elpetro_th50_r=5.15509, z=0.0404168),
 ResultRow(mangaid='1-122151', plateifu='9183-6102', elpetro_absmag_g_r=1.30054664611816, elpetro_th50_r=3.4436, z=0.0124344),
 ResultRow(mangaid='1-122284', plateifu='9183-6101', elpetro_absmag_g_r=1.33587646484375, elpetro_th50_r=3.25321, z=0.0224921),
 ResultRow(mangaid='1-122304', plateifu='9183-3703', elpetro_absmag_g_r=1.27674674987793, elpetro_th50_r=3.87237, z=0.0233453),
 ResultRow(mangaid='1-122329', plateifu='9486-6103', elpetro_absmag_g_r=2.3619499206543, elpetro_th50_r=6.43394, z=0.0982483),
 ResultRow(mangaid='1-122333', plateifu='9486-1901', elpetro_absmag_g_r=1.30059051513672, elpetro_th50_r=3.67772, z=0.0208727),
 ResultRow(mangaid='1-122334', plateifu='9486-6104', elpetro_absmag_g_r=1.59306716918945, elpetro_th50_r=3.71928, z=0.0636345),
 ResultRow(mangaid='1-122361', plateifu='9486-6102', elpetro_absmag_g_r=1.66129302978516, elpetro_th50_r=3.45415, z=0.063881),
 ResultRow(mangaid='1-122364', plateifu='9486-12703', elpetro_absmag_g_r=0.655183792114258, elpetro_th50_r=6.25982, z=0.0369295),
 ResultRow(mangaid='1-122412', plateifu='9486-12705', elpetro_absmag_g_r=1.55437088012695, elpetro_th50_r=3.98716, z=0.0260331),
 ResultRow(mangaid='1-122586', plateifu='9486-1902', elpetro_absmag_g_r=1.61582374572754, elpetro_th50_r=3.69728, z=0.0990185),
 ResultRow(mangaid='1-124604', plateifu='8439-6103', elpetro_absmag_g_r=1.38611221313477, elpetro_th50_r=6.67132, z=0.0253001),
 ResultRow(mangaid='1-133922', plateifu='8486-6104', elpetro_absmag_g_r=1.51949119567871, elpetro_th50_r=5.85332, z=0.0174718),
 ResultRow(mangaid='1-133941', plateifu='8486-9102', elpetro_absmag_g_r=1.04214859008789, elpetro_th50_r=6.9901, z=0.0189045),
 ResultRow(mangaid='1-133945', plateifu='8486-3703', elpetro_absmag_g_r=1.70501899719238, elpetro_th50_r=4.45846, z=0.0183248),
 ResultRow(mangaid='1-133948', plateifu='8486-6103', elpetro_absmag_g_r=1.62374401092529, elpetro_th50_r=5.78962, z=0.0195194),
 ResultRow(mangaid='1-133976', plateifu='8486-9101', elpetro_absmag_g_r=1.26091766357422, elpetro_th50_r=7.11674, z=0.0182938),
 ResultRow(mangaid='1-133987', plateifu='8486-1902', elpetro_absmag_g_r=1.73217391967773, elpetro_th50_r=2.80256, z=0.0195435),
 ResultRow(mangaid='1-134004', plateifu='8486-1901', elpetro_absmag_g_r=1.27153015136719, elpetro_th50_r=2.74306, z=0.0185601),
 ResultRow(mangaid='1-134020', plateifu='8486-6102', elpetro_absmag_g_r=1.4318904876709, elpetro_th50_r=6.70244, z=0.0193267),
 ResultRow(mangaid='1-134209', plateifu='8549-9101', elpetro_absmag_g_r=1.46211814880371, elpetro_th50_r=7.43994, z=0.0545042),
 ResultRow(mangaid='1-134239', plateifu='8549-3703', elpetro_absmag_g_r=1.20720481872559, elpetro_th50_r=5.29078, z=0.0571086),
 ResultRow(mangaid='1-134248', plateifu='8549-3702', elpetro_absmag_g_r=1.04830741882324, elpetro_th50_r=4.19151, z=0.0212204),
 ResultRow(mangaid='1-134293', plateifu='8549-6103', elpetro_absmag_g_r=0.724908828735352, elpetro_th50_r=6.37536, z=0.0416784),
 ResultRow(mangaid='1-134503', plateifu='8555-1901', elpetro_absmag_g_r=1.38505744934082, elpetro_th50_r=2.05563, z=0.0371472),
 ResultRow(mangaid='1-134562', plateifu='8549-1902', elpetro_absmag_g_r=0.999540328979492, elpetro_th50_r=2.21746, z=0.0355137),
 ResultRow(mangaid='1-134597', plateifu='8549-12705', elpetro_absmag_g_r=1.32281875610352, elpetro_th50_r=9.29719, z=0.0441938),
 ResultRow(mangaid='1-134599', plateifu='8549-12704', elpetro_absmag_g_r=1.2156925201416, elpetro_th50_r=8.57387, z=0.019658),
 ResultRow(mangaid='1-134614', plateifu='8549-6102', elpetro_absmag_g_r=1.25503730773926, elpetro_th50_r=6.36671, z=0.0528277),
 ResultRow(mangaid='1-134620', plateifu='9031-12703', elpetro_absmag_g_r=1.27625465393066, elpetro_th50_r=6.19139, z=0.0546778),
 ResultRow(mangaid='1-134634', plateifu='8549-3704', elpetro_absmag_g_r=1.71317291259766, elpetro_th50_r=2.98447, z=0.0523251),
 ResultRow(mangaid='1-134695', plateifu='9029-6104', elpetro_absmag_g_r=1.37136077880859, elpetro_th50_r=5.64757, z=0.0304438),
 ResultRow(mangaid='1-134716', plateifu='8600-12705', elpetro_absmag_g_r=1.10339736938477, elpetro_th50_r=5.6302, z=0.0446535),
 ResultRow(mangaid='1-134737', plateifu='8600-3701', elpetro_absmag_g_r=0.759981155395508, elpetro_th50_r=7.45251, z=0.0272129),
 ResultRow(mangaid='1-134793', plateifu='8600-6104', elpetro_absmag_g_r=0.940788269042969, elpetro_th50_r=4.10349, z=0.0422411),
 ResultRow(mangaid='1-134848', plateifu='8555-12703', elpetro_absmag_g_r=1.4580078125, elpetro_th50_r=8.75956, z=0.0584495),
 ResultRow(mangaid='1-134924', plateifu='8555-9101', elpetro_absmag_g_r=1.76020240783691, elpetro_th50_r=7.2697, z=0.0319997),
 ResultRow(mangaid='1-134954', plateifu='8555-12705', elpetro_absmag_g_r=1.38137054443359, elpetro_th50_r=7.2771, z=0.0315232),
 ResultRow(mangaid='1-134964', plateifu='8555-3701', elpetro_absmag_g_r=1.5971508026123, elpetro_th50_r=4.08391, z=0.0462348),
 ResultRow(mangaid='1-135003', plateifu='8978-3704', elpetro_absmag_g_r=1.6054744720459, elpetro_th50_r=2.54767, z=0.047362),
 ResultRow(mangaid='1-135030', plateifu='8603-12704', elpetro_absmag_g_r=1.31695175170898, elpetro_th50_r=9.51023, z=0.0273289),
 ResultRow(mangaid='1-135044', plateifu='8978-9101', elpetro_absmag_g_r=1.29121780395508, elpetro_th50_r=7.6628, z=0.0303346),
 ResultRow(mangaid='1-135054', plateifu='8550-12703', elpetro_absmag_g_r=1.34156799316406, elpetro_th50_r=8.45056, z=0.0298122),
 ResultRow(mangaid='1-135055', plateifu='8601-6104', elpetro_absmag_g_r=1.68307113647461, elpetro_th50_r=6.24969, z=0.0300581),
 ResultRow(mangaid='1-135057', plateifu='8601-12703', elpetro_absmag_g_r=0.928314208984375, elpetro_th50_r=10.3366, z=0.0288518),
 ResultRow(mangaid='1-135058', plateifu='8603-6103', elpetro_absmag_g_r=1.1861629486084, elpetro_th50_r=5.48034, z=0.0270087),
 ResultRow(mangaid='1-135059', plateifu='9869-3703', elpetro_absmag_g_r=1.56065368652344, elpetro_th50_r=4.51742, z=0.0316739),
 ResultRow(mangaid='1-135072', plateifu='9029-12701', elpetro_absmag_g_r=1.53062629699707, elpetro_th50_r=15.7064, z=0.0324632),
 ResultRow(mangaid='1-135077', plateifu='8312-6104', elpetro_absmag_g_r=1.33458137512207, elpetro_th50_r=4.5256, z=0.0290664),
 ResultRow(mangaid='1-135078', plateifu='9029-12705', elpetro_absmag_g_r=0.914762496948242, elpetro_th50_r=11.8246, z=0.0295154),
 ResultRow(mangaid='1-135086', plateifu='9029-3704', elpetro_absmag_g_r=1.7380199432373, elpetro_th50_r=4.3875, z=0.0332592),
 ResultRow(mangaid='1-135091', plateifu='9029-3702', elpetro_absmag_g_r=1.69864463806152, elpetro_th50_r=5.19483, z=0.0317749),
 ResultRow(mangaid='1-135093', plateifu='9029-12702', elpetro_absmag_g_r=1.25051116943359, elpetro_th50_r=10.9635, z=0.0318872),
 ResultRow(mangaid='1-135095', plateifu='8312-3702', elpetro_absmag_g_r=1.44723129272461, elpetro_th50_r=5.08395, z=0.0332324),
 ResultRow(mangaid='1-135101', plateifu='9869-3701', elpetro_absmag_g_r=1.41915702819824, elpetro_th50_r=5.17462, z=0.0294585),
 ResultRow(mangaid='1-135115', plateifu='9029-3701', elpetro_absmag_g_r=1.5458869934082, elpetro_th50_r=3.82893, z=0.0300883),
 ResultRow(mangaid='1-135117', plateifu='9029-6101', elpetro_absmag_g_r=1.53122138977051, elpetro_th50_r=5.67636, z=0.0333227),
 ResultRow(mangaid='1-135129', plateifu='8603-12705', elpetro_absmag_g_r=1.81981086730957, elpetro_th50_r=7.00506, z=0.0327969),
 ResultRow(mangaid='1-135133', plateifu='8603-12703', elpetro_absmag_g_r=1.36585807800293, elpetro_th50_r=8.37236, z=0.0299683),
 ResultRow(mangaid='1-135134', plateifu='8603-9101', elpetro_absmag_g_r=1.85215187072754, elpetro_th50_r=6.96944, z=0.030343),
 ResultRow(mangaid='1-135142', plateifu='9869-12704', elpetro_absmag_g_r=1.43869781494141, elpetro_th50_r=4.46846, z=0.0326757),
 ResultRow(mangaid='1-135152', plateifu='8312-6103', elpetro_absmag_g_r=0.762582778930664, elpetro_th50_r=5.63706, z=0.0301811),
 ResultRow(mangaid='1-135157', plateifu='8603-3702', elpetro_absmag_g_r=1.68464851379395, elpetro_th50_r=4.97032, z=0.0323713),
 ResultRow(mangaid='1-135193', plateifu='9869-1901', elpetro_absmag_g_r=1.84131813049316, elpetro_th50_r=2.23994, z=0.0308858),
 ResultRow(mangaid='1-135202', plateifu='8600-3703', elpetro_absmag_g_r=1.58297348022461, elpetro_th50_r=8.49454, z=0.0277109),
 ResultRow(mangaid='1-135207', plateifu='8555-1902', elpetro_absmag_g_r=1.51096343994141, elpetro_th50_r=3.59802, z=0.031485),
 ResultRow(mangaid='1-135227', plateifu='9029-6103', elpetro_absmag_g_r=1.5926513671875, elpetro_th50_r=5.6132, z=0.0304491)]

In [7]:
# get the previous set 
p = r.getPrevious()


INFO: Retrieving previous 100, from 0 to 100

To extend your results and keep them, use the extendSet method. By default, extending a set grabs the next page of 100 results (defined by r.chunk) and appends to the existing set of results. Rerunning extendSet continues to append results until you've retrieved them all. To avoid running extendSet multiple times, you can run use the loop method, which will loop over all pages appending the data until you've retrieved all the results.


In [8]:
# extend the set by one page
r.extendSet()
r


INFO: Retrieving next 100, from 100 to 200
Out[8]:
Marvin Results(query=nsa.z < 0.1, totalcount=4275, count=200, mode=remote)

We now have 200 results out of the 4275. For results with a small number of total counts, you can attempt to retrieve all of the results with the getAll method. Currently this method is limited to returning results containing 500,000 rows or rows with 25 columns.

Getting all the results

There are several options for getting all of the results.

  • Use the getAll method to attempt to retrieve all the results in one request.
  • Use the loop method to loop over all the pages to extend/append the results together
  • Rerun the Query using a new limit to retrieve all the results.

Note: A bug was recently found in getAll and might not work. Instead we will rerun the query using a large limit to return all the results.


In [11]:
# get all the results
# r.getAll()

# rerun the query
q = Query(search_filter='nsa.z < 0.1', return_params=['absmag_g_r', 'nsa.elpetro_th50_r'], limit=5000)
r = q.run()
r


Out[11]:
Marvin Results(query=nsa.z < 0.1, totalcount=4275, count=4275, mode=remote)

We now have all the results. We can extract columns of data by indexing the results list using the column name. Let's extract the redshift and color.


In [33]:
# extract individual columns of data
redshift = r.results['nsa.z']
color = r.results['absmag_g_r']

Formatting Results

You can convert the results to a variety of formats using the toXXX methods. Common formats are FITS, Astropy Table, Pandas Dataframe, JSON, or CSV. Only the FITS and CSV conversions will write the output to a file. Astropy Tables and Pandas Dataframes have more options for writing out your dataset to a file. Let's convert to Pandas Dataframe.


In [36]:
# convert the marvin results to a Pandas dataframe
df = r.toDF()
df.head()


Out[36]:
mangaid plateifu elpetro_absmag_g_r elpetro_th50_r z
0 1-109056 8077-6103 1.117039 3.70900 0.047302
1 1-109073 8078-12704 1.059788 7.54724 0.043588
2 1-109081 8077-12705 1.230318 9.60665 0.043859
3 1-109112 8078-1901 1.531988 2.25541 0.024970
4 1-109152 8154-12702 1.543945 16.12630 0.028174

You can also convert the data into Marvin objects using the convertToTool method. This will attempt to convert each result row into its corresponding Marvin Object. The default conversion is to a Cube object. Converted objects are stored in the r.objects attribute. Let's convert our results to cubes. Depending on the number of results, this may take awhile. Let's limit our conversion to 5. Once converted, we now have Marvin Tools at our disposal.


In [37]:
# convert the top 5 to cubes
r.convertToTool('cube', limit=5)


Converting results to Marvin Cube objects

In [38]:
# look at the objects
r.objects


Out[38]:
[<Marvin Cube (plateifu='8077-6103', mode='remote', data_origin='api')>,
 <Marvin Cube (plateifu='8078-12704', mode='remote', data_origin='api')>,
 <Marvin Cube (plateifu='8077-12705', mode='remote', data_origin='api')>,
 <Marvin Cube (plateifu='8078-1901', mode='remote', data_origin='api')>,
 <Marvin Cube (plateifu='8154-12702', mode='remote', data_origin='api')>]

Quickly Plotting the Results

You can quickly plot the full set of results using the plot method. plot accepts two string column names and will attempt to create a scatter plot, a hex-binned plot, or a scatter-density plot, depending on the total number of results. The plot method returns the matplotlib Figure and Axes objects, as well as a dictionary of histogram information for each column. The Results.plot method uses the underlying plot utility function. The utility function offers up more custom plotting options. Let's plot g-r color versus redshift. Regardless of the number of results you currently have loaded, the plot method will automatically retrieve all the results before plotting.


In [18]:
# make a scatter plot
fig, ax, histdata = r.plot('z', 'absmag_g_r')


By default, it will also plot histograms of the column as well. This can be turned off by setting with_hist=False.


In [29]:
# make only a scatter plot
fig, ax = r.plot('z', 'absmag_g_r', with_hist=False)


We can also quickly plot a histogram of a single column of data using the hist method, which uses an underlying hist utility function.


In [39]:
histdata, fig, ax = r.hist('absmag_g_r')


Downloading Results

You can download the raw files from your results using the download method. This uses the downloadList utility function under the hood. By default this will download the DRP cubes for each target row. It accepts any keyword arguments as downloadList.


In [40]:
# download the DRP datacube files from the results 
# r.download()

Additional Resoures

  • Get a refresher on Queries
  • See more details of what you can do with Results
  • See the Results API for a look at the Marvin Results object.

In [ ]: