![]() |
This example shows how to add extra columns to the result.
First, create a new table in your mydb (select context mydb and run a command like the following):
CREATE TABLE MyTable_34 ( objid bigint, ra float, dec float, search_id int, matched_id bigint, z real );
Note that this table includes the extra spec column "z". Add whatever spec columns you want to the end of this table.
Then get the neighbor query by running the neighbor search with your upload file and copying the query in the Query window. Paste that query in a new query buffer in context DR3. Then modify it as in the following example:
CREATE TABLE #UPLOAD( up_ra FLOAT, up_dec FLOAT, up_id int ) INSERT INTO #UPLOAD SELECT RA AS UP_RA,DEC AS UP_DEC,search_id AS UP_ID FROM mydb.MyTable_32 CREATE TABLE #tmp ( up_id int, objid bigint ) INSERT INTO #tmp EXEC spgetneighbors 1 INSERT INTO mydb.MyTable_34 select a.*,t.objid as matched_id, s.z from #tmp t, mydb.MyTable_32 a, specobj s where t.up_id = a.search_id and s.bestobjid=t.objid
Note that the mytable name has been manually set to mytable_34, added "s.z" to the select list (again, add more columns here if you need), "specobj s" to the from, and "and s.bestobjid=t.objid" to the where. You need to run this query in the DR3 context using the Submit button (wont work with Quick).
Here is a way to do a proximity search in casjobs on a list of ra,dec pairs with variable search radius. You should have an ra,dec table called xrayradii. For spGetNeighborsRadius, you have to add another column up_rad to the #upload table.
note that this requires that xrayradii.cluster is an int id that identifies the cluster.
a) Create the table to hold the results:
CREATE TABLE MyTable_45 (
ra float,
dec float,
rad float,
cluster int,
objid bigint,
);
b) Run the neighbors search for variable radius, saving results into table created in a):
CREATE TABLE #UPLOAD(
up_ra FLOAT,
up_dec FLOAT,
up_rad FLOAT,
up_id int
)
INSERT INTO #UPLOAD
SELECT ra AS UP_RA,
dec AS UP_DEC,
xrayradius as UP_RAD,
cluster AS UP_ID
FROM mydb.XrayRadii
CREATE TABLE #tmp (
up_id int,
objid bigint
)
INSERT INTO #tmp
EXEC spGetNeighborsRadius
INSERT INTO mydb.MyTable_45
SELECT a.*, t.objid
FROM #tmp t, mydb.XrayRadii a
WHERE
t.up_id = a.cluster
CREATE mytable_71 (
regionid bigint not null,
type varchar(16) not null
)
mytable_70 contains ra,dec columns and can be imported or created with
another casjobs query to get the ra,dec from phototag.
finally, you run your cursor query in the DR3 context:
declare @ra float, @dec float;
DECLARE my_cursor cursor read_only
FOR select ra,dec
from mydb.mytable_70
OPEN my_cursor
--
WHILE(1=1)
BEGIN
FETCH NEXT from my_cursor into @ra, @dec
IF (@@fetch_status < 0) break
INSERT mydb.mytable_71
SELECT * FROM
dbo.fGetRegionsContainingPoint
END
--------------------
-- close the cursor
--------------------
CLOSE my_cursor
DEALLOCATE my_cursor
you will need to run this with the long queue (submit button, not quick).
select top 10 s.specobjid, s.z as sdssz ,s.ra,s.dec,
'<a href=http://cas.sdss.org/dr3/en/tools/chart/navi.asp?ra='+
cast(s.ra as varchar(10))+
'&dec='+cast( s.dec as varchar(10)) +
'>'+
'<img src="http://casjobs.sdss.org/ImgCutoutDR3/getjpeg.aspx?ra='
+cast(s.ra as varchar(15))+
'&dec='+cast(s.dec as varchar(15))+
'&scale=0.40&width=120&height=120&opt="/> '
as pic
from specphotoall s
Contact MAST
CASJobs is made possible by the Sloan Digital Sky Survey Collaboration
$Name: v2_8_3 $
,$Revision: 1.5 $, Last modified: Monday, November 28, 2005 at 1:15:52 PM