-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch to fix DR12 version of function
For DR12, the path needs to use "boss" instead of "eboss", which only applies from DR13 onwards.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
USE [BestDR12] | ||
GO | ||
|
||
/****** Object: UserDefinedFunction [dbo].[fGetUrlFitsSpectrum] Script Date: 4/20/2023 3:08:52 PM ******/ | ||
SET ANSI_NULLS ON | ||
GO | ||
|
||
SET QUOTED_IDENTIFIER ON | ||
GO | ||
|
||
-- | ||
ALTER FUNCTION [dbo].[fGetUrlFitsSpectrum](@specObjID bigint) | ||
------------------------------------------------- | ||
--/H Get the URL to the FITS file of the spectrum given the SpecObjID | ||
------------------------------------------------- | ||
--/T Combines the value of the DataServer URL from the | ||
--/T SiteConstants table and builds up the whole URL | ||
--/T from the specObjId. | ||
--/T <br><samp> select dbo.fGetUrlFitsSpectrum(75094092974915584)</samp> | ||
------------------------------------------------- | ||
RETURNS varchar(128) | ||
BEGIN | ||
DECLARE @link varchar(128), @plate varchar(8), @mjd varchar(8), | ||
@fiber varchar(8), @rerun varchar(16), @release varchar(8), | ||
@survey varchar(16), @oplate varchar(8), @ofiber varchar(8); | ||
SET @link = (SELECT value FROM SiteConstants WHERE name='DataServerURL'); | ||
SET @release = (select value from SiteConstants where name='Release'); | ||
SELECT @rerun = isnull(p.run2d, p.run1d), @survey = p.survey, | ||
@mjd = cast(p.mjd as varchar(8)), @plate=cast(p.plate as varchar(8)), | ||
@fiber=cast(s.fiberID as varchar(8)) | ||
FROM PlateX p JOIN specObjAll s ON p.plateId=s.plateId | ||
WHERE s.specObjID=@specObjId; | ||
IF @survey != 'boss' | ||
SET @survey = 'sdss' | ||
ELSE | ||
SET @survey = 'boss' | ||
SET @oplate = substring('0000',1,4-len(@plate)) + @plate; | ||
SET @ofiber = substring( '0000',1,4-len(@fiber)) + @fiber; | ||
SET @link = @link + 'sas/dr' + @release + '/' + @survey + '/spectro/redux/' + | ||
@rerun + '/spectra/lite/' + @oplate + '/spec-' + @oplate + '-' + | ||
@mjd + '-' + @ofiber + '.fits'; | ||
RETURN @link; | ||
END | ||
GO | ||
|
||
|