Skip to content

Commit

Permalink
Some minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
matvii committed Sep 12, 2016
1 parent d161d30 commit ceea60a
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 27 deletions.
8 changes: 5 additions & 3 deletions 135_1.ini
Expand Up @@ -64,7 +64,9 @@ EphFile=Hertha/ephm.dat #This file contains the ephemeris information c
# as AO1 and A01) E0=[E0x E0y E0z] is the asteroid->Sun vector and E=[Ex Ey Ez] is asteroid->Earth vector

[Output]
ShapeFile=/tmp/outshape.txt #Write the final shape to this file, in the usual format.
AnglesFile=/tmp/param_1 #Writes the final angles to this file.
LCOutputFile=/tmp/lcout.txt #Writes the final lightcurves to this file.
ShapeFile=Hertha_shape.txt #Write the final shape to this file, in the usual format.
ShapeObjFile=Hertha_shape.obj
StateFile=Hertha_state.txt
AnglesFile=Hertha_angles.txt #Writes the final angles to this file.
LCOutputFile=Hertha_lcout.txt #Writes the final lightcurves to this file.

9 changes: 5 additions & 4 deletions 135_oct.ini
Expand Up @@ -64,7 +64,8 @@ EphFile=Hertha/ephm.dat #This file contains the ephemeris information c
# as AO1 and A01) E0=[E0x E0y E0z] is the asteroid->Sun vector and E=[Ex Ey Ez] is asteroid->Earth vector

[Output]
ShapeFile=/tmp/outshape.txt #Write the final shape to this file, in the usual format.
AnglesFile=/tmp/param_1 #Writes the final angles to this file.
LCOutputFile=/tmp/lcout.txt #Writes the final lightcurves to this file.
StateFile=/tmp/state.txt
ShapeFile=Hertha_shape.txt #Write the final shape to this file, in the usual format.
ShapeObjFile=Hertha_shape.obj #Shape file, in obj format
StateFile=Hertha_state.txt
AnglesFile=Hertha_angles.txt #Writes the final angles to this file.
LCOutputFile=Hertha_lcout.txt #Writes the final lightcurves to this file.
2 changes: 1 addition & 1 deletion README.md
@@ -1,6 +1,6 @@
#ADAM: All-Data Asteroid Modelling

ADAM is a program for 3D shape reconstruction of asteroids from disk-resolved observations. Current version supports lightcurves, albedo variegation, adaptive optics, occultations, and range-Doppler radar images. Raw images are used directly, boundary extraction is not needed. Source code for thermal modelling is also included, but not currently integrated into main program due to lack of available observations (Juno is currently the only one).
ADAM is a program for 3D shape reconstruction of asteroids from disk-resolved observations. Current version supports lightcurves, albedo variegation, adaptive optics, occultations, and range-Doppler radar images. Raw images are used directly, boundary extraction is not required. Source code for thermal modelling is also included, but not currently integrated into main program.

##Required libraries
- KissFFT (https://sourceforge.net/projects/kissfft)
Expand Down
1 change: 1 addition & 0 deletions adam.ini
Expand Up @@ -90,5 +90,6 @@ ShapeFile=/tmp/OutputShape.txt #Write the final shape to this file, in the
AnglesFile=/tmp/Angles.txt #Writes the final angles to this file.
LCOutputFile=/tmp/lcout.txt #Writes the final lightcurves to this file.
ShapeParamFile=/tmp/Pshape.txt #Parameters used for shape
ShapeObjFile=/tmp/state.obj #Write the final shape to this file, in obj format
#RDOffsetFile=/tmp/RDoffset.txt #range-Doppler offset output file
StateFile=/tmp/state.txt #Write all final parameters to this file
26 changes: 16 additions & 10 deletions fit_oct_model_to_LC_AO.c
Expand Up @@ -658,7 +658,13 @@ void fit_oct_model_to_LC_AO(LCstruct *LC,AOstruct *AO,OCstruct *OC,RDstruct *RD)
}

// printf("Offsets: %f %f %f %f\n",offset[0],offset[1],offset[2],offset[3]);
printf("Writing shape information to %s\n",OUT_SHAPE_FILE);
write_shape_file(OUT_SHAPE_FILE,tlist,vlist,nfac,nvert);
if( OUT_OBJSHAPE_FILE!=NULL)
{
printf("Writing obj shape to: %s\n",OUT_OBJSHAPE_FILE);
write_obj_file(OUT_OBJSHAPE_FILE,tlist,vlist,nfac,nvert);
}
FILE* fid=fopen(OUT_PARAM_FILE,"w");
FILE* fidlc=fopen(OUT_LC_FILE,"w");
if(fidlc!=NULL)
Expand Down Expand Up @@ -692,7 +698,7 @@ void fit_oct_model_to_LC_AO(LCstruct *LC,AOstruct *AO,OCstruct *OC,RDstruct *RD)
write_matrix_file(OUT_SHAPE_PARAM_FILE,a,1,alength);
if(INI_WRITE_STATE_FILE!=NULL)
{
printf("Writing state file:\n");
printf("Writing state file %s:\n",INI_WRITE_STATE_FILE);
FILE *fp;
fp=fopen(INI_WRITE_STATE_FILE,"w");
if(fp==NULL)
Expand All @@ -710,20 +716,20 @@ void fit_oct_model_to_LC_AO(LCstruct *LC,AOstruct *AO,OCstruct *OC,RDstruct *RD)
}
if(INI_FIT_ALBEDO==1)
{
fprintf(fp,"#Albedo:\n");
fprintf(fp,"#Albedo: %d\n",nfac);
for(int j=0;j<nfac;j++)
fprintf(fp,"%.2f ",Alblimits[0]+(Alblimits[1]-Alblimits[0])*exp(eAlbedo[j])/(exp(eAlbedo[j])+1.0));
fprintf(fp,"\n");
}
//Shape parameters
fprintf(fp,"#Shape:\n");
fprintf(fp,"#LMAX: %d\n",INI_LMAX);
fprintf(fp,"#Params:\n");
fprintf(fp,"#Params: %d\n",alength);
for(int j=0;j<alength;j++)
fprintf(fp,"%.4f ",a[j]);
fprintf(fp,"\n");

fprintf(fp,"#Polyhedron:\n");
fprintf(fp,"#Polyhedron: %d %d\n",nfac,nvert);
for(int j=0;j<3*nfac;j++)
fprintf(fp,"%d ",tlist[j]);
fprintf(fp,"\n");
Expand All @@ -732,33 +738,33 @@ void fit_oct_model_to_LC_AO(LCstruct *LC,AOstruct *AO,OCstruct *OC,RDstruct *RD)
fprintf(fp,"\n");
if(INI_HAVE_AO)
{
fprintf(fp,"#AOoffset:\n");
fprintf(fp,"#AOoffset: %d\n",nAOoffsets);
for(int j=0;j<nAOoffsets;j++)
fprintf(fp,"%.4f ",AOoffset[j]);
fprintf(fp,"\n");
fprintf(fp,"#AOscale:\n");
fprintf(fp,"#AOscale: %d\n",nAOscale);
for(int j=0;j<nAOscale;j++)
fprintf(fp,"%.4f ",AOscale[j]);
fprintf(fp,"\n");
}
if(INI_HAVE_OC)
{
fprintf(fp,"#OCCoffset:\n");
fprintf(fp,"#OCCoffset: %d\n",nOCoffsets);
for(int j=0;j<nOCoffsets;j++)
fprintf(fp,"%.4f ",OCoffset[j]);
fprintf(fp,"\n");
fprintf(fp,"#Chordoffset:\n");
fprintf(fp,"#Chordoffset: %d\n",nChordoffsets);
for(int j=0;j<nChordoffsets;j++)
fprintf(fp,"%.4f ",Chordoffset[j]);
fprintf(fp,"\n");
}
if(INI_HAVE_RD)
{
fprintf(fp,"#RDoffset:\n");
fprintf(fp,"#RDoffset: %d\n",nRDoffsets);
for(int j=0;j<nRDoffsets;j++)
fprintf(fp,"%.4f ",RDoffset[j]);
fprintf(fp,"\n");
fprintf(fp,"#RDscale:\n");
fprintf(fp,"#RDscale: %d\n",nRDscale);
for(int j=0;j<nRDscale;j++)
fprintf(fp,"%.4f ",RDscale[j]);
}
Expand Down
25 changes: 16 additions & 9 deletions fit_subdiv_model_to_LC_AO.c
Expand Up @@ -693,6 +693,7 @@ void fit_subdiv_model_to_LC_AO(LCstruct *LC,AOstruct *AO,OCstruct *OC,RDstruct *

}
Sqrt3_Subdiv(tlist,vlist,nfac,nvert,&tlistn,&vlistn,&nfacn,&nvertn,&D,INI_SD_LEVEL);
printf("Writing shape information to %s\n",OUT_SHAPE_FILE);
write_shape_file(OUT_SHAPE_FILE,tlistn,vlistn,nfacn,nvertn);
FILE* fid=fopen(OUT_PARAM_FILE,"w");
FILE* fidlc=fopen(OUT_LC_FILE,"w");
Expand Down Expand Up @@ -729,12 +730,18 @@ void fit_subdiv_model_to_LC_AO(LCstruct *LC,AOstruct *AO,OCstruct *OC,RDstruct *
write_shape_file(OUT_SHAPE_PARAM_FILE,tlist,vlist,nfac,nvert);
if(INI_OUTPUT_AO_OFFSET!=NULL)
write_matrix_file(INI_OUTPUT_AO_OFFSET,AOoffset,1,nAOoffsets);
if( OUT_OBJSHAPE_FILE!=NULL)
{
printf("Writing obj shape to: %s\n",OUT_OBJSHAPE_FILE);
write_obj_file(OUT_OBJSHAPE_FILE,tlistn,vlistn,nfacn,nvertn);
}
// print_matrix(params,1,4);
/*
* writing final state of all fitted variables to file
*/
if(INI_WRITE_STATE_FILE!=NULL)
{
printf("Writing all variables to %s\n",INI_WRITE_STATE_FILE);
FILE *fp;
fp=fopen(INI_WRITE_STATE_FILE,"w");
if(fp==NULL)
Expand All @@ -752,22 +759,22 @@ void fit_subdiv_model_to_LC_AO(LCstruct *LC,AOstruct *AO,OCstruct *OC,RDstruct *
}
if(INI_FIT_ALBEDO==1)
{
fprintf(fp,"#Albedo:\n");
fprintf(fp,"#Albedo: %d\n",nfacn);
for(int j=0;j<nfacn;j++)
fprintf(fp,"%.2f ",Alblimits[0]+(Alblimits[1]-Alblimits[0])*exp(eAlbedo[j])/(exp(eAlbedo[j])+1.0));
fprintf(fp,"\n");
}
//Shape parameters
fprintf(fp,"#Shape:\n");
fprintf(fp,"#SDlevel: %d\n",INI_SD_LEVEL);
fprintf(fp,"#Params:\n");
fprintf(fp,"#Params: %d %d\n",nfac,nvert);
for(int j=0;j<3*nfac;j++)
fprintf(fp,"%d ",tlist[j]);
fprintf(fp,"\n");
for(int j=0;j<3*nvert;j++)
fprintf(fp,"%.4f ",vlist[j]);
fprintf(fp,"\n");
fprintf(fp,"#Polyhedron:\n");
fprintf(fp,"#Polyhedron: %d %d\n",nfacn,nvertn);
for(int j=0;j<3*nfacn;j++)
fprintf(fp,"%d ",tlistn[j]);
fprintf(fp,"\n");
Expand All @@ -776,33 +783,33 @@ void fit_subdiv_model_to_LC_AO(LCstruct *LC,AOstruct *AO,OCstruct *OC,RDstruct *
fprintf(fp,"\n");
if(INI_HAVE_AO)
{
fprintf(fp,"#AOoffset:\n");
fprintf(fp,"#AOoffset: %d\n",nAOoffsets);
for(int j=0;j<nAOoffsets;j++)
fprintf(fp,"%.4f ",AOoffset[j]);
fprintf(fp,"\n");
fprintf(fp,"#AOscale:\n");
fprintf(fp,"#AOscale: %d\n",nAOscale);
for(int j=0;j<nAOscale;j++)
fprintf(fp,"%.4f ",AOscale[j]);
fprintf(fp,"\n");
}
if(INI_HAVE_OC)
{
fprintf(fp,"#OCCoffset:\n");
fprintf(fp,"#OCCoffset: %d\n",nOCoffsets);
for(int j=0;j<nOCoffsets;j++)
fprintf(fp,"%.4f ",OCoffset[j]);
fprintf(fp,"\n");
fprintf(fp,"#Chordoffset:\n");
fprintf(fp,"#Chordoffset: %d\n",nChordoffsets);
for(int j=0;j<nChordoffsets;j++)
fprintf(fp,"%.4f ",Chordoffset[j]);
fprintf(fp,"\n");
}
if(INI_HAVE_RD)
{
fprintf(fp,"#RDoffset:\n");
fprintf(fp,"#RDoffset: %d\n",nRDoffsets);
for(int j=0;j<nRDoffsets;j++)
fprintf(fp,"%.4f ",RDoffset[j]);
fprintf(fp,"\n");
fprintf(fp,"#RDscale:\n");
fprintf(fp,"#RDscale: %d\n",nRDscale);
for(int j=0;j<nRDscale;j++)
fprintf(fp,"%.4f ",RDscale[j]);
}
Expand Down
1 change: 1 addition & 0 deletions globals.h
Expand Up @@ -70,6 +70,7 @@ extern int INI_FREE_CHORD_NMR;
extern int *INI_PHASE_MASK;
extern char *INI_WRITE_STATE_FILE;
extern char *INI_ALBEDO_OUT_FILE;
extern char *OUT_OBJSHAPE_FILE;
extern double INI_NDCHORD_WEIGHT;
extern int INI_LOGEXP;
#endif
7 changes: 7 additions & 0 deletions parse_ini.c
Expand Up @@ -76,6 +76,7 @@ double INI_NDCHORD_WEIGHT=1000;
int INI_LOGEXP=4;
char *INI_WRITE_STATE_FILE=NULL;
char *INI_ALBEDO_OUT_FILE=NULL;
char *OUT_OBJSHAPE_FILE=NULL;
int parse_ini(char *filename)
{
char *ephmfile;
Expand Down Expand Up @@ -286,6 +287,12 @@ int parse_ini(char *filename)
}
OUT_SHAPE_FILE=calloc(strlen(s)+1,sizeof(char));
strcpy(OUT_SHAPE_FILE,s);
s=iniparser_getstring(ini,"Output:ShapeObjFile",NULL);
if(s!=NULL)
{
OUT_OBJSHAPE_FILE=calloc(strlen(s)+1,sizeof(char));
strcpy(OUT_OBJSHAPE_FILE,s);
}
s=iniparser_getstring(ini,"Output:AnglesFile",NULL);
if(s==NULL)
{
Expand Down
19 changes: 19 additions & 0 deletions utils.c
Expand Up @@ -622,6 +622,25 @@ void read_shape(char* filename,int **facets2,double** vertices2,int *nfac2,int *
*facets2=facets;
*vertices2=vertices;
}
void write_obj_file(char *file,int *tlist,double *vlist,int nfac,int nvert)
{
/*
* Write shape file in obj (wavefront) format
*/
FILE *fp;
fp=fopen(file,"w");
if(fp==NULL)
{
fprintf(stderr,"Cannot open file %s for writing the shape in obj format\n",file);
exit(-1);
}

for(int j=0;j<nvert;j++)
fprintf(fp,"v %.4f %.4f %.4f\n",vlist[3*j],vlist[3*j+1],vlist[3*j+2]);
for(int j=0;j<nfac;j++)
fprintf(fp,"f %d %d %d\n",tlist[3*j],tlist[3*j+1],tlist[3*j+2]);
fclose(fp);
}
void Calculate_Normals(int *tlist,double *vlist,int nfac,int nvert,double *normal)
{
/*INPUT:
Expand Down
1 change: 1 addition & 0 deletions utils.h
Expand Up @@ -13,6 +13,7 @@
#include<string.h>
#include"structs.h"
#include"wcstools-3.9.2/libwcs/fitsfile.h"
void write_obj_file(char *file,int *tlist,double *vlist,int nfac,int nvert);
void AdjFacet(int *tlist,double *vlist,int nfac,int nvert,int *A);
void localsmooth(int *tlist,double *vlist,int nfac,int nvert,double *ealb,double *Alim,double *res,double *drda);
int parse_vector(char *string,double *vec,int maxlength);
Expand Down

0 comments on commit ceea60a

Please sign in to comment.