I have an ASCII file (.con) with the coordinates of vertices of different contours. This file is obtained from Matlab. Now after every set of contour ends there needs to be a blank row in the contour file. In place of this, I have a row with Nan Nan in it when Matlab writes the file. What I do is simply find and Replace the Nan with nothing. But when I load the contour file in ds9 it gives me weird contours. I'm also posting the result I expect (fig 1) and the result I'm getting (fig 2). The problem here that I've understood till now is that if I copy and paste every contour block of coordinates separately into the .con file the result is as expected but I want the whole process of writing the contours from Matlab into the file such that it gives me the expected result in ds9 to be automated (basically I don't want to copy and paste every block). Can somebody help with this?

This is what I expect:

This is what I expect

This is what I get

Link for the .con file that gives the right result: https://drive.google.com/open?id=1tDMXtmywJnSjpi_CzCI5-F85oFpebnl4

Link for the .con file that gives the wrong result: https://drive.google.com/file/d/18rgN1UVtvcyfJSuh1mmbqOVQCna_aAUM/view

  • $\begingroup$ Can you share a small sample .con file before and after you edit it? $\endgroup$ – samcarter_is_at_topanswers.xyz Oct 4 '19 at 14:06
  • $\begingroup$ You mean the one which gives the right result and the one which does not? or before and after I delete the NaNs? $\endgroup$ – Shakti Oct 4 '19 at 18:32
  • $\begingroup$ yes, it does not need to be the whole file, two blocks would be enough. (my suspicion is that it might be related to spaces, tabs or something like that) $\endgroup$ – samcarter_is_at_topanswers.xyz Oct 4 '19 at 19:59
  • $\begingroup$ I've added the files. To me, there does not seem to be any space tab difference between the two $\endgroup$ – Shakti Oct 6 '19 at 6:01
  • $\begingroup$ There is indeed a difference with tabs: in conto.con the empty line consist of linebreak+tab+linebreak, in contop.con it is linebreak+linebreak. $\endgroup$ – samcarter_is_at_topanswers.xyz Oct 7 '19 at 12:55

The solution as pointed out by samcarter in the above comment was to remove the tab in conto.con so that it had linebreak + linebreak instead of linebreak + tab + linebreak

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.