From paxton at kitp.ucsb.edu Thu Dec 7 22:03:56 2006 From: paxton at kitp.ucsb.edu (Bill Paxton) Date: Thu, 7 Dec 2006 19:03:56 -0800 Subject: [Tioga-users] converting PDF to EPS on the Mac Message-ID: <8AFB426D-F85F-4EEC-AF1B-56B8110A8344@kitp.ucsb.edu> Hello, Some journals seem to insist on getting figures in PostScript rather than PDF which means a final conversion step for Tioga figures. There are various ways to do this (some of which use ghostscript I know), but there is now a very easy to use solution for the Mac. It comes from here: http://insti.physics.sunysb.edu/~siegel/x.shtml First, you need to install xpdf-tools http://users.phg-online.de/tk/MOSXS/xpdf-tools-3.dmg Then install droppdftoeps http://insti.physics.sunysb.edu/~siegel/Droppdftoeps.dmg drag the icon to applications and to the dock. then drag and drop a pdf file for the figure to the droppdftoeps icon, and soon after a eps version of the file appears in the same folder. seems to work (based on 2 tests, one line plot and one sampled image plot). Cheers, Bill From astanin at calvino.polito.it Tue Dec 12 07:14:02 2006 From: astanin at calvino.polito.it (Sergey Astanin) Date: Tue, 12 Dec 2006 13:14:02 +0100 (CET) Subject: [Tioga-users] multiple figures in one class: only the first works Message-ID: <44518.130.192.22.39.1165925642.squirrel@matmail.polito.it> Good day to everyone! I am a new Tioga user, and I am trying to write a class with multiple figures (all plots use the same data). I use a derived batch class as suggested in the tutorial for plotting. I noticed that while there is only one figure per class, it works well, but when there are two figures, t.make_preview_pdf(name) always makes the first one, no matter what figure name is supplied. For example, I attach to this message a script test.rb with TestPlots and TestPlotsBatch classes. The former contains two t.def_figure() calls and debug printing, the latter should make preview of all figures. However, when I run it I see that $ ruby test.rb Make Blue.pdf DEBUG: plot_blue cd figures_out; pdflatex -interaction nonstopmode Blue.tex > pdflatex.log Make Red.pdf DEBUG: plot_blue cd figures_out; pdflatex -interaction nonstopmode Blue.tex > pdflatex.log What am I doing wrong? How I should define/use multiple figures? I am using tioga 1.2.1 in Linux. Best regards, Sergey Astanin. -------------- next part -------------- A non-text attachment was scrubbed... Name: test.rb Type: application/x-ruby Size: 755 bytes Desc: not available Url : http://rubyforge.org/pipermail/tioga-users/attachments/20061212/36296ebc/attachment.bin From astanin at calvino.polito.it Tue Dec 12 08:43:54 2006 From: astanin at calvino.polito.it (Sergey Astanin) Date: Tue, 12 Dec 2006 14:43:54 +0100 (CET) Subject: [Tioga-users] multiple figures in one class: only the first works In-Reply-To: <44518.130.192.22.39.1165925642.squirrel@matmail.polito.it> References: <44518.130.192.22.39.1165925642.squirrel@matmail.polito.it> Message-ID: <45051.130.192.22.39.1165931034.squirrel@matmail.polito.it> > $ ruby test.rb > > Make Blue.pdf > DEBUG: plot_blue > cd figures_out; pdflatex -interaction nonstopmode Blue.tex > pdflatex.log > > Make Red.pdf > DEBUG: plot_blue > cd figures_out; pdflatex -interaction nonstopmode Blue.tex > pdflatex.log > > What am I doing wrong? How I should define/use multiple figures? I am > using tioga 1.2.1 in Linux. I have found a solution, instead of make_preview_pdf(name) def run t.figure_names.each do |name| puts "\nMake #{name}.pdf" t.make_preview_pdf(name) end end make_preview_pdf(number) should be used: def run 0.upto(t.num_figures-1) do |i| t.make_preview_pdf(i) end end It seems that make_preview_pdf(name) is working like make_preview_pdf(0) and gives no warnings. I guess samples/ subdirectory of tioga (figures/sample_batch.rb, plots/run.rb, sine.rb) should be updated according to this bahaviour. Tutorial should be updated too [1]. 1. http://theory.kitp.ucsb.edu/~paxton/tioga_doc/classes/Tioga/Tutorial/DocStructure.html Best regards, Sergey Astanin From edder at tkwsping.nl Tue Dec 12 08:34:39 2006 From: edder at tkwsping.nl (Edwin) Date: Tue, 12 Dec 2006 13:34:39 -0000 Subject: [Tioga-users] monochrome image Message-ID: Hi all, I have a lot of x,y data, with corresponding z values and am trying to plot a contourplot. A normal contourplot is working well using the following: t.show_plot( [0, 1, 1, 0] ) { image = t.create_image_data( zs, 'min_value' => -0.8, 'max_value' => 0.8 ) t.show_image( 'll' => [0, 0], 'lr' => [1, 0], 'ul' => [0, 1], 'color_space' => t.mellow_colormap, 'data' => image, 'w' => steps+1, 'h' => steps+1) } But I'm actually only interested if the value is above or below 0 and want to plot everything above 0 grey and keep everything else white. I think I need the create_monochrome_image_data for that but can't figure it out. I tried just setting: t.create_image_data( zs, 'boundary' => 0.0 ) and 'color_space' => 'mono', but this doesn't seem to work (I get a plot, but it doesn't match in anyway with the data). I also tried setting the stencil_mask in show_image, but got the following error: undefined method `each_key' for # [version: 1.2.1] What is the correct way to do this? Edwin From astanin at calvino.polito.it Tue Dec 12 10:02:03 2006 From: astanin at calvino.polito.it (Sergey Astanin) Date: Tue, 12 Dec 2006 16:02:03 +0100 (CET) Subject: [Tioga-users] monochrome image In-Reply-To: References: Message-ID: <37460.130.192.22.39.1165935723.squirrel@matmail.polito.it> Hello! > But I'm actually only interested if the value is above or below 0 and want > to plot everything above 0 grey and keep everything else white. I think I > need the create_monochrome_image_data for that but can't figure it out. I think they may be done with custom colormap, something like this: bicolor_colormap = t.create_colormap( 'length' => 4, 'points' => [ 0.0, 0.5-1e-99, 0.5+1e-99, 1.0 ], 'Rs' => [ 0.3, 0.3, 1.0, 1.0 ], 'Gs' => [ 0.3, 0.3, 1.0, 1.0 ], 'Bs' => [ 0.3, 0.3, 1.0, 1.0 ] ) and use it in t.show_image. This way you could make one half of the image range appear in gray (rgb:0.3,0.3,0.3), and the other half in white (rgb:1.0,1.0,1.0), with very narrow transition region. Choosing 'min_value' and 'max_value' symmetrically would place this transition region in data's zero. However, I have not tried plotting bicolor images. Let us know if it works. My use case seems to be close to yours. Best regards, Sergey Astanin. From paxton at kitp.ucsb.edu Tue Dec 12 11:13:04 2006 From: paxton at kitp.ucsb.edu (Bill Paxton) Date: Tue, 12 Dec 2006 08:13:04 -0800 Subject: [Tioga-users] multiple figures in one class: only the first works In-Reply-To: <44518.130.192.22.39.1165925642.squirrel@matmail.polito.it> References: <44518.130.192.22.39.1165925642.squirrel@matmail.polito.it> Message-ID: <6AA5A289-9AA4-4895-AC6B-14B6C0F947CC@kitp.ucsb.edu> On Dec 12, 2006, at 4:14 AM, Sergey Astanin wrote: > t.make_preview_pdf(name) always makes the first one, no matter what > figure > name is supplied Hi Sergey, The technical term for what you discovered is a "bug" ; - ) In the about-to-be-released new version, "make_preview_pdf" has become an obsolete alias for the routine "make_pdf". Unless I've screwed up something else, make_pdf now takes either a number or a name for the figure and deals correctly with multiple figures in a class. Cheers, Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/tioga-users/attachments/20061212/2be6a0bb/attachment.html From edder at tkwsping.nl Tue Dec 12 11:13:54 2006 From: edder at tkwsping.nl (Edwin) Date: Tue, 12 Dec 2006 16:13:54 -0000 Subject: [Tioga-users] monochrome image In-Reply-To: <37460.130.192.22.39.1165935723.squirrel@matmail.polito.it> References: <37460.130.192.22.39.1165935723.squirrel@matmail.polito.it> Message-ID: On Tue, 12 Dec 2006 15:02:03 -0000, Sergey Astanin wrote: > > Best regards, > Sergey Astanin. I'm actually thinking about using make_contour and then just t.fill to fill the resulting area. I think this should work well, but I still have the feeling it should also be possible with monochrome_image and I am curious if someone knows how. Edwin From astanin at calvino.polito.it Tue Dec 12 11:54:58 2006 From: astanin at calvino.polito.it (Sergey Astanin) Date: Tue, 12 Dec 2006 17:54:58 +0100 (CET) Subject: [Tioga-users] monochrome image In-Reply-To: References: <37460.130.192.22.39.1165935723.squirrel@matmail.polito.it> Message-ID: <52633.130.192.22.39.1165942498.squirrel@matmail.polito.it> > I'm actually thinking about using make_contour and then just t.fill to > fill the resulting area. I think this should work well, but I still have > the feeling it should also be possible with monochrome_image and I am > curious if someone knows how. > > Edwin I think banded colormap would be a more generic solution (it does not require contour to be closed and regions to be connected), but t.fill may probably produce more attractive results for low resolution data with simple or a priory known geometry of positive/negative regions. Anyway, please let me know how you do this finally. Sergey. From astanin at calvino.polito.it Tue Dec 12 12:10:11 2006 From: astanin at calvino.polito.it (Sergey Astanin) Date: Tue, 12 Dec 2006 18:10:11 +0100 (CET) Subject: [Tioga-users] multiple figures in one class: only the first works In-Reply-To: <6AA5A289-9AA4-4895-AC6B-14B6C0F947CC@kitp.ucsb.edu> References: <44518.130.192.22.39.1165925642.squirrel@matmail.polito.it> <6AA5A289-9AA4-4895-AC6B-14B6C0F947CC@kitp.ucsb.edu> Message-ID: <35101.130.192.22.39.1165943411.squirrel@matmail.polito.it> Hi Bill, > The technical term for what you discovered is a "bug" ; - ) It is not easy for me to judge whether it is a bug or a feature. I am glad that you qualified it as bug and already fixed :) Regards, Sergey. P.S. It took a long time before I dared to try Tioga (I knew about it when it was packaged for Debian). And I find it a very nice tool. Thank you for developing and maintaining it. It is really a joy to produce high quality scalable plots with properly written labels, colormaps and contours. From paxton at kitp.ucsb.edu Tue Dec 12 12:28:33 2006 From: paxton at kitp.ucsb.edu (Bill Paxton) Date: Tue, 12 Dec 2006 09:28:33 -0800 Subject: [Tioga-users] monochrome image In-Reply-To: <52633.130.192.22.39.1165942498.squirrel@matmail.polito.it> References: <37460.130.192.22.39.1165935723.squirrel@matmail.polito.it> <52633.130.192.22.39.1165942498.squirrel@matmail.polito.it> Message-ID: Hi, Here's a little example of a monochrome image using checkerboard data. def mono_image table = build_table(0.1, 0.9) samples = t.create_monochrome_image_data(table, 'boundary' => 0.5) t.fill_color = Black t.show_image( 'width' => 8, 'height' => 8, 'color_space' => 'mono', 'data' => samples, 'interpolate' => false, 'll' => [0.1, 0.1], 'lr' => [0.9, 0.1], 'ul' => [0.1, 0.9]) end Here are two screen captures showing the result: The first one is from Adobe's acroread (naturally, it looks like it should): -------------- next part -------------- A non-text attachment was scrubbed... Name: acroread_version.tiff Type: image/tiff Size: 11172 bytes Desc: not available Url : http://rubyforge.org/pipermail/tioga-users/attachments/20061212/0e2a61dc/attachment-0002.tiff -------------- next part -------------- The second is from Apple's preview (and unfortunately it isn't so great): -------------- next part -------------- A non-text attachment was scrubbed... Name: preview_version.tiff Type: image/tiff Size: 56180 bytes Desc: not available Url : http://rubyforge.org/pipermail/tioga-users/attachments/20061212/0e2a61dc/attachment-0003.tiff -------------- next part -------------- It seems that Apple doesn't pay attention to the flag that should control interpolation. I've included the pdf file below in case you'd like to check your favorite viewer! Cheers, Bill Here's the checkerboard data: def build_table(light, dark) num_cols = 8 num_rows = 8 table = Dtable.new(num_cols, num_rows) row0 = Dvector[light, dark, light, dark, light, dark, light, dark] row1 = Dvector[dark, light, dark, light, dark, light, dark, light] table.set_row(0,row0) table.set_row(1,row1) table.set_row(2,row0) table.set_row(3,row1) table.set_row(4,row0) table.set_row(5,row1) table.set_row(6,row0) table.set_row(7,row1) return table end Here's the PDF file: -------------- next part -------------- A non-text attachment was scrubbed... Name: mono_image.pdf Type: application/pdf Size: 1787 bytes Desc: not available Url : http://rubyforge.org/pipermail/tioga-users/attachments/20061212/0e2a61dc/attachment-0001.pdf From paxton at kitp.ucsb.edu Tue Dec 12 12:54:53 2006 From: paxton at kitp.ucsb.edu (Bill Paxton) Date: Tue, 12 Dec 2006 09:54:53 -0800 Subject: [Tioga-users] monochrome image In-Reply-To: References: <37460.130.192.22.39.1165935723.squirrel@matmail.polito.it> Message-ID: <63C7C543-E86A-406C-A0AA-F713EEAE7CC4@kitp.ucsb.edu> On Dec 12, 2006, at 8:13 AM, Edwin wrote: > I'm actually thinking about using make_contour and then just t.fill to > fill the resulting area. I think this should work well Hi Edwin, Unfortunately, you may not be happy with the results if you do a fill with the contours. I've used the "industry standard" contour finding algorithm, and it seems to work okay for stroked contours. But if you take a very close-up look at the contours you'll see that they are doing goofy things with lots of tiny zigs and zags and a large number of breaks, none of which are really necessary. (Try printing out the number of gaps in a typical contour -- you'll be amazed!) If you can suggest a better contour finding algorithm, we could give it a try. But I'm afraid this is one of those problems that turns out to be a lot more difficult that it looks at first. Here's the link to a description of the current routine: http://local.wasp.uwa.edu.au/~pbourke/papers/conrec/ --Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/tioga-users/attachments/20061212/ce43daa2/attachment.html From edder at tkwsping.nl Tue Dec 12 16:12:54 2006 From: edder at tkwsping.nl (Edwin) Date: Tue, 12 Dec 2006 21:12:54 -0000 Subject: [Tioga-users] monochrome image In-Reply-To: References: <37460.130.192.22.39.1165935723.squirrel@matmail.polito.it> <52633.130.192.22.39.1165942498.squirrel@matmail.polito.it> Message-ID: On Tue, 12 Dec 2006 17:28:33 -0000, Bill Paxton wrote: > Here's a little example of a monochrome image using checkerboard data. > > def mono_image > table = build_table(0.1, 0.9) > samples = t.create_monochrome_image_data(table, 'boundary' > => 0.5) > t.fill_color = Black > t.show_image( > 'width' => 8, > 'height' => 8, > 'color_space' => 'mono', > 'data' => samples, > 'interpolate' => false, > 'll' => [0.1, 0.1], > 'lr' => [0.9, 0.1], > 'ul' => [0.1, 0.9]) > end Maybe I'm missing how create_monochrome_image_data should be used, but it only seems to work correctly with a 8x8 table anything smaller produces the wrong pattern and anything bigger produces a parse error in acroread (evince is still able to parse it, but also shows the wrong picture). I tested this with my own data and 8x8 parses fine indeed, but anything else also produced the wrong results. Below is an edited version of Bill's test program for a 10x10 table. Edited program: def test table = build_table(0.1, 0.9) samples = t.create_monochrome_image_data(table, 'boundary' => 0.5) t.fill_color = Black t.show_image( 'width' => 10, 'height' => 10, 'color_space' => 'mono', 'data' => samples, 'll' => [0.0, 0.0], 'lr' => [0.9, 0.0], 'ul' => [0.0, 0.9]) end def build_table(light, dark) num_cols = 10 num_rows = 10 table = Dtable.new(num_cols, num_rows) row0 = Dvector[light, dark, light, dark, light, dark, light, dark, light,dark] row1 = Dvector[dark, light, dark, light, dark, light, dark, light, dark,light] table.set_row(0,row0) table.set_row(1,row1) table.set_row(2,row0) table.set_row(3,row1) table.set_row(4,row0) table.set_row(5,row1) table.set_row(6,row0) table.set_row(7,row1) table.set_row(8,row0) table.set_row(9,row1) return table end Edwin From edder at tkwsping.nl Tue Dec 12 15:26:30 2006 From: edder at tkwsping.nl (Edwin) Date: Tue, 12 Dec 2006 20:26:30 -0000 Subject: [Tioga-users] monochrome image In-Reply-To: References: <37460.130.192.22.39.1165935723.squirrel@matmail.polito.it> <52633.130.192.22.39.1165942498.squirrel@matmail.polito.it> Message-ID: On Tue, 12 Dec 2006 17:28:33 -0000, Bill Paxton wrote: > Here's a little example of a monochrome image using checkerboard data. > > def mono_image > table = build_table(0.1, 0.9) > samples = t.create_monochrome_image_data(table, 'boundary' > => 0.5) > t.fill_color = Black > t.show_image( > 'width' => 8, > 'height' => 8, > 'color_space' => 'mono', > 'data' => samples, > 'interpolate' => false, > 'll' => [0.1, 0.1], > 'lr' => [0.9, 0.1], > 'ul' => [0.1, 0.9]) > end Maybe I'm missing how create_monochrome_image_data should be used, but it only seems to work correctly with a 8x8 table anything smaller produces the wrong pattern and anything bigger produces a parse error in acroread (evince is still able to parse it, but also shows the wrong picture). I tested this with my own data and 8x8 parses fine indeed, but anything else also produced the wrong results. Below is an edited version of Bill's test program for a 10x10 table. I also attached the resulting pdf Edited program: def test table = build_table(0.1, 0.9) samples = t.create_monochrome_image_data(table, 'boundary' => 0.5) t.fill_color = Black t.show_image( 'width' => 10, 'height' => 10, 'color_space' => 'mono', 'data' => samples, 'll' => [0.0, 0.0], 'lr' => [0.9, 0.0], 'ul' => [0.0, 0.9]) end def build_table(light, dark) num_cols = 10 num_rows = 10 table = Dtable.new(num_cols, num_rows) row0 = Dvector[light, dark, light, dark, light, dark, light, dark, light,dark] row1 = Dvector[dark, light, dark, light, dark, light, dark, light, dark,light] table.set_row(0,row0) table.set_row(1,row1) table.set_row(2,row0) table.set_row(3,row1) table.set_row(4,row0) table.set_row(5,row1) table.set_row(6,row0) table.set_row(7,row1) table.set_row(8,row0) table.set_row(9,row1) return table end Edwin -------------- next part -------------- A non-text attachment was scrubbed... Name: test.pdf Type: application/pdf Size: 1776 bytes Desc: not available Url : http://rubyforge.org/pipermail/tioga-users/attachments/20061212/f56fbf46/attachment.pdf From roym at ce.washington.edu Tue Dec 12 16:16:50 2006 From: roym at ce.washington.edu (Roy Mayfield) Date: Tue, 12 Dec 2006 13:16:50 -0800 Subject: [Tioga-users] monochrome image In-Reply-To: <63C7C543-E86A-406C-A0AA-F713EEAE7CC4@kitp.ucsb.edu> References: <37460.130.192.22.39.1165935723.squirrel@matmail.polito.it> <63C7C543-E86A-406C-A0AA-F713EEAE7CC4@kitp.ucsb.edu> Message-ID: <457F1C42.3040202@ce.washington.edu> > On Dec 12, 2006, at 8:13 AM, Edwin wrote: > >> I'm actually thinking about using make_contour and then just t.fill to >> >> fill the resulting area. I think this should work well >> > Bill Paxton wrote: > > > Hi Edwin, > > Unfortunately, you may not be happy with the results if you do a fill > with the contours. > > I've used the "industry standard" contour finding algorithm, and it > seems to work okay for stroked contours. But if you take a very > close-up look at the contours you'll see that they are doing goofy > things with lots of tiny zigs and zags and a large number of breaks, > none of which are really necessary. (Try printing out the number of > gaps in a typical contour -- you'll be amazed!) > > If you can suggest a better contour finding algorithm, we could give it > a try. But I'm afraid this is one of those problems that turns out to > be a lot more difficult that it looks at first. > > Here's the link to a description of the current routine: > http://local.wasp.uwa.edu.au/~pbourke/papers/conrec/ > > --Bill > Hi Bill, I'm not a contouring whizbang but have been pleased with the results from the GRI graphing package (http://gri.sourceforge.net/). Dan Kelley (Oceanography Dept, Dalhousie University) is the primary author and has been fine-tuning this GPL'd software for about 15 yrs now. The contours that it produces don't seem to be jagged or broken like those from the CONREC routine that you describe, especially when one of 3 types of smoothing are specified. When I pull the contours into xfig (via pstoedit), they come in as continuous polylines and I can select the entire line with one click. Dan has also taken a shot at labeling the contours. They aren't perfect in all cases, but are surprisingly, um, ok. -- Roy From paxton at kitp.ucsb.edu Tue Dec 12 18:16:54 2006 From: paxton at kitp.ucsb.edu (Bill Paxton) Date: Tue, 12 Dec 2006 15:16:54 -0800 Subject: [Tioga-users] monochrome image In-Reply-To: References: <37460.130.192.22.39.1165935723.squirrel@matmail.polito.it> <52633.130.192.22.39.1165942498.squirrel@matmail.polito.it> Message-ID: <5AE45F46-888B-41B3-A308-5384BE129615@kitp.ucsb.edu> > Maybe I'm missing how create_monochrome_image_data should be used, > but it > only seems to work correctly with a 8x8 table Hi Edwin, Gee, why would you want anything other than 8x8? ; - ) Turns out 16x16, 24x24, etc. all work too. PDF and I seem to have had a difference of opinion about dealing with padding bytes at ends of rows. I've now switched to doing it their way -- so the new release will have the fix. Cheers, Bill -------------- next part -------------- A non-text attachment was scrubbed... Name: six_by_six.tiff Type: image/tiff Size: 20130 bytes Desc: not available Url : http://rubyforge.org/pipermail/tioga-users/attachments/20061212/26ed7052/attachment-0001.tiff -------------- next part -------------- From paxton at kitp.ucsb.edu Wed Dec 13 00:49:56 2006 From: paxton at kitp.ucsb.edu (Bill Paxton) Date: Tue, 12 Dec 2006 21:49:56 -0800 Subject: [Tioga-users] monochrome image In-Reply-To: <457F1C42.3040202@ce.washington.edu> References: <37460.130.192.22.39.1165935723.squirrel@matmail.polito.it> <63C7C543-E86A-406C-A0AA-F713EEAE7CC4@kitp.ucsb.edu> <457F1C42.3040202@ce.washington.edu> Message-ID: <4F2C614F-F98E-433B-AD40-02A505DCCCF4@kitp.ucsb.edu> On Dec 12, 2006, at 1:16 PM, Roy Mayfield wrote: > Hi Bill, > > I'm not a contouring whizbang but have been pleased with the > results from the GRI graphing package (http:// > gri.sourceforge.net/). Dan Kelley (Oceanography Dept, Dalhousie > University) is the primary author and has been fine-tuning this > GPL'd software for about 15 yrs now. Hi Roy, Thanks for the pointer -- I've now downloaded the GRI tar file, extracted the relevant routines, translated from C++ to dull-boring old C, and look what we've got! -------------- next part -------------- A non-text attachment was scrubbed... Name: grad_ad.pdf Type: application/pdf Size: 36278 bytes Desc: not available Url : http://rubyforge.org/pipermail/tioga-users/attachments/20061212/7e143409/attachment-0001.pdf -------------- next part -------------- This plot is done with fill_and_stroke on the results from the new make_contour (it shows the regions where the values are <= 0.165). Great fun! BTW: I'm leaving the old CONREC algorithm in as an option in case the new one runs into trouble for someone. Cheers, Bill