[prev in list] [next in list] [prev in thread] [next in thread] 

List:       monetdb-checkins
Subject:    MonetDB: default - Simple functionality for FITS files:
From:       Milena Ivanova <Milena.Ivanova () cwi ! nl>
Date:       2010-11-26 16:10:14
Message-ID: hg.f69826a9545c.1290787814.6315528441665844383 () localhost ! localdomain
[Download RAW message or body]

Changeset: f69826a9545c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f69826a9545c
Modified Files:
	sql/src/backends/monet5/sql.mx
	sql/src/backends/monet5/vaults/72_fits.mal
	sql/src/backends/monet5/vaults/Makefile.ag
	sql/src/backends/monet5/vaults/fits.mx
Branch: default
Log Message:

Simple functionality for FITS files:
fits.attach(filename) reads the metainformation about tables in a given FITS
file and fills the SQL FITS catalog tables: fits_files, fits_tables, and fits_columns.


diffs (truncated from 500 to 300 lines):

diff -r 655e1bb30e9b -r f69826a9545c sql/src/backends/monet5/sql.mx
--- a/sql/src/backends/monet5/sql.mx	Fri Nov 26 16:12:16 2010 +0100
+++ b/sql/src/backends/monet5/sql.mx	Fri Nov 26 17:10:05 2010 +0100
@@ -275,10 +275,6 @@
 comment "Import a table from bstream s with the 
 	given tuple and seperators (sep/rsep)";
 
-pattern fitsView(fname :str):void
-address fits_view
-comment "Open a FITS file and return catalog of the table HDUs";
-
 function single(x:any_2):bat[:oid,:any_2];
 	b := bat.new(0:oid, x);
 	c := bat.append(b, x);
@@ -1034,7 +1030,6 @@
 #include "sql_emptyset.h"
 
 #include <bat/bat_storage.h>
-/* #include "fitsio.h" */
 
 @-
 The back-end structure collects the information needed to support
@@ -1278,7 +1273,6 @@
 @:numcastdown_export(wrd,lng)@
 
 sql5_export str getContext(Client cntxt, MalBlkPtr mb, mvc **c, backend **b );
-sql5_export str fits_view(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 
 #endif /* _SQL_H */
 
@@ -5500,49 +5494,3 @@
 #endif /* RDF */
 }
 
-str fits_view(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
-{
-	mvc *m = NULL;
-	sql_schema *sch;
-	sql_table *fits_tbl,  *fits_col;
-	str msg = MAL_SUCCEED; 
-	str fname = *(str*) getArgReference(stk, pci, 1);
-	int id;
-	
-
-	msg = getContext(cntxt, mb, &m, NULL);
-	if (msg)
-		return msg;
-	sch = mvc_bind_schema(m,"sys");
-
-	fits_tbl = mvc_bind_table(m, sch, "fits_tables");
-	if ( fits_tbl == NULL ){
-		fits_tbl = mvc_create_table(m, sch, "fits_tables", tt_table, 0, SQL_PERSIST, 0, 4);
-		mvc_create_column_(m, fits_tbl, "id","int",32);
-		mvc_create_column_(m, fits_tbl, "name","varchar",80);
-		mvc_create_column_(m, fits_tbl, "filename","varchar",80);
-		mvc_create_column_(m, fits_tbl, "hdu","int",32);
-	}
-	fits_col = mvc_bind_table(m, sch, "fits_columns");
-	if ( fits_col == NULL ){
-		fits_col = mvc_create_table(m, sch, "fits_columns", tt_table, 0, SQL_PERSIST, 0, 6);
-		mvc_create_column_(m, fits_col, "id","int",32);
-		mvc_create_column_(m, fits_col, "name","varchar",80);
-		mvc_create_column_(m, fits_col, "type","varchar",80);
-		mvc_create_column_(m, fits_col, "type_digits","int",32);
-		mvc_create_column_(m, fits_col, "table_id","int",32);
-		mvc_create_column_(m, fits_col, "units","varchar",10);
-	}
-	
-	id = 1;
-	store_funcs.append_col(m->session->tr,
-			mvc_bind_column(m, fits_tbl, "id"), &id, TYPE_int);
-	store_funcs.append_col(m->session->tr,
-			mvc_bind_column(m, fits_tbl, "name"), fname, TYPE_str);
-	store_funcs.append_col(m->session->tr,
-			mvc_bind_column(m, fits_tbl, "filename"), "test.fit", TYPE_str);
-	id = 2;
-	store_funcs.append_col(m->session->tr,
-			mvc_bind_column(m, fits_tbl, "hdu"), &id, TYPE_int);
-	return MAL_SUCCEED;
-}   
diff -r 655e1bb30e9b -r f69826a9545c sql/src/backends/monet5/vaults/72_fits.mal
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sql/src/backends/monet5/vaults/72_fits.mal	Fri Nov 26 17:10:05 2010 +0100
@@ -0,0 +1,20 @@
+# The contents of this file are subject to the MonetDB Public License
+# Version 1.1 (the "License"); you may not use this file except in
+# compliance with the License. You may obtain a copy of the License at
+# http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+# License for the specific language governing rights and limitations
+# under the License.
+#
+# The Original Code is the MonetDB Database System.
+#
+# The Initial Developer of the Original Code is CWI.
+# Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+# Copyright August 2008-2010 MonetDB B.V.
+# All Rights Reserved.
+
+# This loads the MonetDB/SQL module
+library fits;
+include fits;
diff -r 655e1bb30e9b -r f69826a9545c sql/src/backends/monet5/vaults/Makefile.ag
--- a/sql/src/backends/monet5/vaults/Makefile.ag	Fri Nov 26 16:12:16 2010 +0100
+++ b/sql/src/backends/monet5/vaults/Makefile.ag	Fri Nov 26 17:10:05 2010 +0100
@@ -15,32 +15,14 @@
 # Copyright August 2008-2010 MonetDB B.V.
 # All Rights Reserved.
 
-INCLUDES = ../../include ../../common ../../storage ../../server ../ \
-	$(MONETDB5_INCS) $(CLIENTS_INCS) $(MONETDB_INCS) $(READLINE_INCS) $(MSEED_CFLAGS)
+INCLUDES = ../../../include ../../../common ../../../storage ../../../server ../ \
+	$(MONETDB5_INCS) $(CLIENTS_INCS) $(MONETDB_INCS) $(READLINE_INCS) $(MSEED_CFLAGS) $(CFITSIO_CFLAGS)
 
 lib__vault = {
 	DIR = libdir/MonetDB5/
 	SOURCES = vault.mx
 	LIBS = $(MONETDB5_LIBS) -lmonetdb5 \
-		$(MONETDB_LIBS) -lbat
-}
-
-headers_h = {
-	HEADERS = h
-	DIR = includedir/MonetDB5/sql
-	SOURCES = vault.mx
-}
-
-headers_mal = {
-	HEADERS = mal
-	DIR = libdir/MonetDB5
-	SOURCES = vault.mx vault.sql
-}
-
-headers_autoload = {
-	HEADERS = mal
-	DIR = libdir/MonetDB5/autoload
-	SOURCES = 70_vault.mal
+		$(MONETDB_LIBS) -lbat $(MSEED_LIBS) 
 }
 
 lib__mseed = {
@@ -51,11 +33,17 @@
 		$(MONETDB_LIBS) -lbat $(MSEED_LIBS)
 }
 
-headers_mseedautoload = {
-	COND = HAVE_MSEED
-	HEADERS = mal
-	DIR = libdir/MonetDB5/autoload
-	SOURCES = 71_mseed.mal
+lib__fits = {
+    COND = HAVE_CFITSIO
+    DIR = libdir/MonetDB5/
+    SOURCES = fits.mx
+    LIBS = $(MONETDB5_LIBS) -lmonetdb5 $(MONETDB_LIBS) $(CFITSIO_LIBS)
+}
+
+headers_h = {
+	HEADERS = h
+	DIR = includedir/MonetDB5/sql
+	SOURCES = vault.mx
 }
 
 headers_mseedh = {
@@ -65,6 +53,19 @@
 	SOURCES = mseed.mx
 }
 
+headers_fitsh = {
+	COND = HAVE_CFITSIO
+	HEADERS = h
+	DIR = includedir/MonetDB5/sql
+	SOURCES = fits.mx
+}
+
+headers_mal = {
+	HEADERS = mal
+	DIR = libdir/MonetDB5
+	SOURCES = vault.mx vault.sql
+}
+
 headers_mseedmal = {
 	COND = HAVE_MSEED
 	HEADERS = mal
@@ -72,5 +73,32 @@
 	SOURCES = mseed.mx
 }
 
+headers_fitsmal = {
+	COND = HAVE_CFITSIO
+	HEADERS = mal
+	DIR = libdir/MonetDB5
+	SOURCES = fits.mx
+}
+
+headers_autoload = {
+	HEADERS = mal
+	DIR = libdir/MonetDB5/autoload
+	SOURCES = 70_vault.mal
+}
+
+headers_mseedautoload = {
+	COND = HAVE_MSEED
+	HEADERS = mal
+	DIR = libdir/MonetDB5/autoload
+	SOURCES = 71_mseed.mal
+}
+
+headers_fitsautoload = {
+    COND = HAVE_CFITSIO
+    HEADERS = mal
+    DIR = libdir/MonetDB5/autoload
+    SOURCES = 72_fits.mal
+}
+
 EXTRA_DIST_DIR = Tests
-EXTRA_DIST = 70_vault.mal 71_mseed.mal vault.sql
+EXTRA_DIST = 70_vault.mal 71_mseed.mal vault.sql 72_fits.mal
diff -r 655e1bb30e9b -r f69826a9545c sql/src/backends/monet5/vaults/fits.mx
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sql/src/backends/monet5/vaults/fits.mx	Fri Nov 26 17:10:05 2010 +0100
@@ -0,0 +1,276 @@
+@' The contents of this file are subject to the MonetDB Public License
+@' Version 1.1 (the "License"); you may not use this file except in
+@' compliance with the License. You may obtain a copy of the License at
+@' http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
+@'
+@' Software distributed under the License is distributed on an "AS IS"
+@' basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+@' License for the specific language governing rights and limitations
+@' under the License.
+@'
+@' The Original Code is the MonetDB Database System.
+@'
+@' The Initial Developer of the Original Code is CWI.
+@' Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+@' Copyright August 2008-2010 MonetDB B.V.
+@' All Rights Reserved.
+
+@a M. Ivanova, M. Kersten, N. Nes
+@f fits
+@- This module contains primitives for accessing data in FITS file format.
+
+@{
+@-
+@mal
+module fits;
+
+command fitstest(filename:str):int
+address FITStest
+comment "Returns the type of first extension in the FITS file filename";
+
+pattern attach(fname :str):void
+address FITSattach
+comment "Open a FITS file and return catalog of the table HDUs";
+
+
+@h
+#ifndef _FITS_
+#define _FITS_
+#undef htype
+#undef ttype
+#include "fitsio.h"
+#include "fitsio2.h"
+#include "longnam.h"
+#include "sql_config.h"
+#include <sql_mvc.h>
+#include <sql.h>
+#include "clients.h"
+#include "mal.h" 
+#include "mal_client.h"
+#include "mal_exception.h" 
+
+#ifdef WIN32
+#ifndef LIBFITS
+#define fits_export extern __declspec(dllimport)
+#else
+#define fits_export extern __declspec(dllexport)
+#endif
+#else
+#define fits_export extern
+#endif
+
+fits_export str FITStest(int *res, str *fname);
+fits_export str FITSattach(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
+#endif
+
+@-
+
+@c
+#include "fits.h"
+
+str
+FITStest(int *res, str *fname)
+{
+    fitsfile *fptr;       /* pointer to the FITS file, defined in fitsio.h */
+	str msg = MAL_SUCCEED;
+    int status = 0, hdutype;
_______________________________________________
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic