Skip to content

Commit

Permalink
Patch to fix DR12 version of function
Browse files Browse the repository at this point in the history
For DR12, the path needs to use "boss" instead of "eboss", which only applies from DR13 onwards.
  • Loading branch information
thakar committed Apr 20, 2023
1 parent 28e691f commit c2bb76c
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions schema/patches/fGetUrlFitsSpectrumDR12.sql
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


0 comments on commit c2bb76c

Please sign in to comment.