Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SophyaExtLibs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
SOPHYA
SophyaExtLibs
Commits
16088247
Commit
16088247
authored
24 years ago
by
ansari
Browse files
Options
Downloads
Patches
Plain Diff
classe FITS_AutoReader
parent
691e8c6b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
FitsIOServer/fitsautoreader.cc
+211
-0
211 additions, 0 deletions
FitsIOServer/fitsautoreader.cc
FitsIOServer/fitsautoreader.h
+55
-0
55 additions, 0 deletions
FitsIOServer/fitsautoreader.h
with
266 additions
and
0 deletions
FitsIOServer/fitsautoreader.cc
0 → 100644
+
211
−
0
View file @
16088247
#include
"pexceptions.h"
#include
"fitsautoreader.h"
#include
"dvlist.h"
///////////////////////////////////////////////////////////////////////
// ---- gestion de persistance I/O format fits--
// objets
////////////////////////////////////////////////////////////////////
FITS_AutoReader
::
FITS_AutoReader
()
{
InitNull
();};
FITS_AutoReader
::
FITS_AutoReader
(
const
char
inputfile
[])
{
InitNull
();
inFits_
=
new
FitsInFile
(
inputfile
);
}
FITS_AutoReader
::
FITS_AutoReader
(
string
const
&
inputfile
)
{
InitNull
();
inFits_
=
new
FitsInFile
(
inputfile
);
}
FITS_AutoReader
::~
FITS_AutoReader
()
{
if
(
inFits_
!=
NULL
)
delete
inFits_
;
if
(
dobj_
!=
NULL
)
delete
dobj_
;
}
AnyDataObj
*
FITS_AutoReader
::
ReadObject
(
int
hdunum
)
const
{
inFits_
->
ReadHeader
(
hdunum
);
DVList
dvl
=
inFits_
->
DVListFromFits
();
string
nameObj
=
dvl
.
GetS
(
"CONTENT"
);
cout
<<
" SOPHYA object identified as: "
<<
dvl
.
GetS
(
"CONTENT"
)
<<
endl
;
if
(
nameObj
==
string
(
"TArray"
)
)
{
return
newTArray
();
}
else
if
(
nameObj
==
string
(
"SphereHEALPix"
)
)
{
return
newSphereHEALPix
();
}
else
if
(
nameObj
==
string
(
"LocalMap"
)
)
{
return
newLocalMap
();
}
else
if
(
nameObj
==
string
(
"NTuple"
)
)
{
return
newNTuple
();
}
else
if
(
nameObj
==
string
(
"XNTuple"
)
)
{
return
newXNTuple
();
}
// on n'a trouve aucun nom d'objet connu de SOPHYA, on fait une
// recherche qualitative.
//
// si c'est une image fits, on cree un TArray
else
if
(
inFits_
->
IsFitsImage
())
{
return
newTArray
();
}
// si c'est une bintable on cherche le mot cle ORDERING pour identifier
// une spherehelpix
else
if
(
inFits_
->
IsFitsTable
())
{
if
(
dvl
.
GetS
(
"ORDERING"
)
!=
string
(
""
))
return
newSphereHEALPix
();
// sinon on cherche ntuple ou xntuple
else
{
int
index
=
0
;
for
(
int
k
=
0
;
k
<
inFits_
->
NbColsFromFits
();
k
++
)
{
if
(
inFits_
->
ColTypeFromFits
(
k
)
!=
FitsFile
::
FitsDataType_float
)
{
index
=
1
;
break
;
}
}
if
(
index
==
0
)
return
newNTuple
();
else
return
newXNTuple
();
}
}
else
{
throw
IOExc
(
"FITS_AutoReader::ReadObject : object not recognized as a SOPHYA object"
);
}
}
AnyDataObj
*
FITS_AutoReader
::
newTArray
()
const
{
FitsFile
::
FitsDataType
dtype
=
inFits_
->
ImageType
();
switch
(
dtype
)
{
case
FitsFile
::
FitsDataType_double
:
{
TArray
<
r_8
>*
matptr
=
new
TArray
<
r_8
>
;
FITS_TArray
<
r_8
>
fta
(
matptr
);
fta
.
Read
(
*
inFits_
,
inFits_
->
currentHeaderIndex
());
return
matptr
;
}
case
FitsFile
::
FitsDataType_float
:
{
TArray
<
r_4
>*
matptr
=
new
TArray
<
r_4
>
;
FITS_TArray
<
r_4
>
fta
(
matptr
);
fta
.
Read
(
*
inFits_
,
inFits_
->
currentHeaderIndex
());
return
matptr
;
}
case
FitsFile
::
FitsDataType_int
:
{
TArray
<
int_4
>*
matptr
=
new
TArray
<
int_4
>
;
FITS_TArray
<
int_4
>
fta
(
matptr
);
fta
.
Read
(
*
inFits_
,
inFits_
->
currentHeaderIndex
());
return
matptr
;
}
default
:
cout
<<
"type = "
<<
dtype
<<
endl
;
throw
IOExc
(
"FITS_AutoReader::ReadObject : unsupported data type for TArray"
);
}
}
AnyDataObj
*
FITS_AutoReader
::
newSphereHEALPix
()
const
{
FitsFile
::
FitsDataType
dtype
;
if
(
inFits_
->
IsFitsTable
())
dtype
=
inFits_
->
ColTypeFromFits
(
0
);
else
{
cout
<<
" WARNING : Sperehealpix not binary table : unusual "
<<
endl
;
dtype
=
inFits_
->
ImageType
();
}
switch
(
dtype
)
{
case
FitsFile
::
FitsDataType_double
:
{
SphereHEALPix
<
r_8
>*
sphptr
=
new
SphereHEALPix
<
r_8
>
;
FITS_SphereHEALPix
<
r_8
>
fta
(
sphptr
);
fta
.
Read
(
*
inFits_
,
inFits_
->
currentHeaderIndex
());
return
sphptr
;
}
case
FitsFile
::
FitsDataType_float
:
{
SphereHEALPix
<
r_4
>*
sphptr
=
new
SphereHEALPix
<
r_4
>
;
FITS_SphereHEALPix
<
r_4
>
fta
(
sphptr
);
fta
.
Read
(
*
inFits_
,
inFits_
->
currentHeaderIndex
());
return
sphptr
;
}
case
FitsFile
::
FitsDataType_int
:
{
SphereHEALPix
<
int_4
>*
sphptr
=
new
SphereHEALPix
<
int_4
>
;
FITS_SphereHEALPix
<
int_4
>
fta
(
sphptr
);
fta
.
Read
(
*
inFits_
,
inFits_
->
currentHeaderIndex
());
return
sphptr
;
}
default
:
cout
<<
"type = "
<<
dtype
<<
endl
;
throw
IOExc
(
"FITS_AutoReader::ReadObject : unsupported data type for SphereHEALpix"
);
}
}
AnyDataObj
*
FITS_AutoReader
::
newLocalMap
()
const
{
FitsFile
::
FitsDataType
dtype
;
if
(
inFits_
->
IsFitsTable
())
dtype
=
inFits_
->
ColTypeFromFits
(
0
);
else
{
cout
<<
" WARNING : Localmap not binary table : unusual "
<<
endl
;
dtype
=
inFits_
->
ImageType
();
}
switch
(
dtype
)
{
case
FitsFile
::
FitsDataType_double
:
{
LocalMap
<
r_8
>*
locmptr
=
new
LocalMap
<
r_8
>
;
FITS_LocalMap
<
r_8
>
fta
(
locmptr
);
fta
.
Read
(
*
inFits_
,
inFits_
->
currentHeaderIndex
());
return
locmptr
;
}
case
FitsFile
::
FitsDataType_float
:
{
LocalMap
<
r_4
>*
locmptr
=
new
LocalMap
<
r_4
>
;
FITS_LocalMap
<
r_4
>
fta
(
locmptr
);
fta
.
Read
(
*
inFits_
,
inFits_
->
currentHeaderIndex
());
return
locmptr
;
}
case
FitsFile
::
FitsDataType_int
:
{
LocalMap
<
int_4
>*
locmptr
=
new
LocalMap
<
int_4
>
;
FITS_LocalMap
<
int_4
>
fta
(
locmptr
);
fta
.
Read
(
*
inFits_
,
inFits_
->
currentHeaderIndex
());
return
locmptr
;
}
default
:
cout
<<
"type = "
<<
dtype
<<
endl
;
throw
IOExc
(
"FITS_AutoReader::ReadObject : unsupported data type for LocalMap"
);
}
}
NTuple
*
FITS_AutoReader
::
newNTuple
()
const
{
NTuple
*
ntptr
=
new
NTuple
;
FITS_NTuple
fta
(
ntptr
);
fta
.
Read
(
*
inFits_
,
inFits_
->
currentHeaderIndex
());
return
ntptr
;
}
XNTuple
*
FITS_AutoReader
::
newXNTuple
()
const
{
XNTuple
*
xntptr
=
new
XNTuple
;
FITS_XNTuple
fta
(
xntptr
);
fta
.
Read
(
*
inFits_
,
inFits_
->
currentHeaderIndex
());
return
xntptr
;
}
This diff is collapsed.
Click to expand it.
FitsIOServer/fitsautoreader.h
0 → 100644
+
55
−
0
View file @
16088247
#ifndef FITSAUTOREADER_SEEN
#define FITSAUTOREADER_SEEN
// Guy Le Meur 11/2000
#include
"machdefs.h"
#include
"anydataobj.h"
#include
"fitsfile.h"
#include
"fitstarray.h"
#include
"fitsspherehealpix.h"
#include
"fitsntuple.h"
#include
"fitsxntuple.h"
#include
"fitslocalmap.h"
namespace
SOPHYA
{
///////////////////////////////////////////////////////////////////////
// ------------- Classe pour la gestion de persistance I/O format fits--
// des objets
//////////////////////////////////////////////////////////////////////
class
FITS_AutoReader
{
public:
FITS_AutoReader
();
FITS_AutoReader
(
const
char
inputfile
[]);
FITS_AutoReader
(
string
const
&
inputfile
);
virtual
~
FITS_AutoReader
();
AnyDataObj
*
ReadObject
(
int
hdunum
=
0
)
const
;
private
:
AnyDataObj
*
newTArray
()
const
;
AnyDataObj
*
newSphereHEALPix
()
const
;
AnyDataObj
*
newLocalMap
()
const
;
NTuple
*
newNTuple
()
const
;
XNTuple
*
newXNTuple
()
const
;
inline
void
InitNull
()
{
inFits_
=
NULL
;
dobj_
=
NULL
;
ownobj_
=
false
;
}
FitsInFile
*
inFits_
;
AnyDataObj
*
dobj_
;
bool
ownobj_
;
};
}
// Fin du namespace
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment