View Issue Details

IDProjectCategoryView StatusLast Update
0001833CCdciel[All Projects] Generalpublic17-11-07 11:02
ReporterhanAssigned To 
Status closedResolutionduplicate 
Product Version0.9 
Target VersionFixed in Version 
Summary0001833: PlateSolve2 doesn't work if in Windows a komma s separator is defined.
DescriptionPlateSolve2 follows Windows definition of decimal separator. I little awkward since it is difficult to get info out of the APM file with comma's as separator and also as decimal separator. Also the yx ratio can be reported as a single 1 or as 1,0011. Below the code to fix. Only the decimal separator detection has to be done in the startup phase of CCDciel.
Also a sample file with yx ratio=1, difficult to detect.

 comma_sep:=(FormatSettings.decimalseparator=',');{. or , settings country settings}
 { to be detected before setting forcing dot separator since it is used by PlateSolve2 for producing APM file};

procedure TAstrometry_engine.Apm2Wcs;
// communicated by Han Kleijn
  i,pos1,pos2,pos3,sign : integer;
  f : textfile;
  line1, line2,line3 :string;
  hdr: THeaderBlock;
  fwcs: file of THeaderBlock;
  cd1_1,cd1_2,cd2_1,cd2_2: double;
  flipped: boolean;

  function strtofloat2(s:string): double;{accept either dot or komma as decimal seperator}
     s:=StringReplace(s,',','.',[]); {replaces comma by dot}
     if error1<>0 then result:=0;
  // Reopen the file for reading
  while not Eof(f) do
  if length(line3)=20 then {valid solution}
  if length(line3)=20 then {valid solution}
    pos1:=posex(',',line1,1); {variable length and decimal sign=comma complicates readout}
    if comma_sep then pos1:=posex(',',line1,pos1+1); {take next comma}
    if comma_sep then pos2:=posex(',',line1,pos2+1); {take next comma}

    ra_radians:=strtofloat2(copy(line1,1,pos1-1));{contains . or , depending on country settings}

    pos1:=posex(',',line2,1); {variable length and decimal sign=comma complicates readout}
    if comma_sep then pos1:=posex(',',line2,pos1+1); {take next comma}
    if comma_sep then pos2:=posex(',',line2,pos2+1); {take next comma}

    flipped:= line2[pos3+1]<>'-';{y/x ratio, if positive then flipped. For comma separators could be written as "1" or "-0,9999" or "1,0011". So line2 could contain 7 or 8 comma's!! Therefore check only for "-"}

    {in apm file yx ratio is reported inverse compared with PlateSolve2 window}
    if flipped then
      crota2:=180-crota2; {Non-standard angle reporting in Platesolve2}
    crota1:=crota2; { coordinate grid is not skewed= > crota1=crota2}

    // old_to_new_WCS
    if cdelt1>=0 then sign:=+1 else sign:=-1;
    if cdelt2>=0 then sign:=+1 else sign:=-1;
    cd2_2:= cdelt2*cos(crota2*pi/180);

    // write header
    for i:=1 to 36 do
    hdr[1] := 'COMMENT Solved by Platesolve 2'+blank80;
    hdr[2] := 'CTYPE1 = '+#39+'RA---TAN'+#39+' / first parameter RA , projection TANgential'+blank80;
    hdr[3] := 'CTYPE2 = '+#39+'DEC--TAN'+#39+' / second parameter DEC, projection TANgential'+blank80;
    hdr[4] := 'CUNIT1 = '+#39+'deg '+#39+' / Unit of coordinate '+blank80;
    hdr[5] := 'CRPIX1 = '+FormatFloat(e6, 0.5+Fiwidth/2)+' / X of reference pixel '+blank80;
    hdr[6] := 'CRPIX2 = '+FormatFloat(e6, 0.5+Fiheight/2)+' / Y of reference pixel '+blank80;
    hdr[7] := 'CRVAL1 = '+FormatFloat(e6,ra_radians*rad2deg)+' / RA of reference pixel (deg) '+blank80;
    hdr[8] := 'CRVAL2 = '+FormatFloat(e6,dec_radians*rad2deg)+' / DEC of reference pixel (deg) '+blank80;
    hdr[9] := 'CDELT1 = '+FormatFloat(e6,cdelt1)+' / X pixel size (deg) '+blank80;
    hdr[10] := 'CDELT2 = '+FormatFloat(e6,cdelt2)+' / Y pixel size (deg) '+blank80;
    hdr[11] := 'CROTA1 = '+FormatFloat(e6,crota1)+' / Image twist of X axis (deg) '+blank80;
    hdr[12] := 'CROTA2 = '+FormatFloat(e6,crota2)+' / Image twist of Y axis (deg) '+blank80;
    hdr[13] := 'CD1_1 = '+FormatFloat(e6,cd1_1)+' / CD matrix to convert (x,y) to (Ra, Dec) '+blank80;
    hdr[14] := 'CD1_2 = '+FormatFloat(e6,cd1_2)+' / CD matrix to convert (x,y) to (Ra, Dec) '+blank80;
    hdr[15] := 'CD2_1 = '+FormatFloat(e6,cd2_1)+' / CD matrix to convert (x,y) to (Ra, Dec) '+blank80;
    hdr[16] := 'CD2_2 = '+FormatFloat(e6,cd2_2)+' / CD matrix to convert (x,y) to (Ra, Dec) '+blank80;
    hdr[17] := 'END'+blank80;

    // write wcs file

    // mark as solved
    write(f,' ');

TagsNo tags attached.


duplicate of 0001834 resolvedPatrick Chevalley PlateSolve2 doesn't work if in Windows a komma s separator is defined. 


There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
17-11-06 17:17 han New Issue
17-11-07 11:02 Patrick Chevalley Status new => closed
17-11-07 11:02 Patrick Chevalley Resolution open => duplicate
17-11-07 11:02 Patrick Chevalley Relationship added duplicate of 0001834