D-69 Subject: Re: Why does mathematica randomly rewrite notebooks? > I'm trying to manage mathematica notebooks in a revision control system > trivial changes seemingly randomly. Does anyone know why? > Here's an example: > @@ -860,7 +862,7 @@ > (Tuu[i, j] Xd[j] // ToFlavor[natbasis]), n, > (((% /. > x : Xd[_] [RuleDelayed] (TransformIndexFlavor[ > - natbasis, {[Lambda]form}])[x])(n)([IndentingNewLine]) > + natbasis, {[Lambda]form}])[x])([IndentingNewLine])(n) > ) (*[IndentingNewLine](% // SumExpansion[natbasis /@ {i, j}]) // > SumExpansion[[Lambda]form[k]][IndentingNewLine]%%[IndentingNewLine]*) ), > The line starting with '-' shows what was there, and the line starting > with '+' shows that change that mathematica made at the last save. > Notice the at the order of the n and the IndentingNewLine have been > reversed. This appears to happen at random. > WRI, is there anything I can do to prevent this, or is it a bug/feature? > Joe > -- > Josef Karthauser (joe@tao.org.uk) http://www.josef-k.net/ > FreeBSD (cvs meister, admin and hacker) http://www.uk.FreeBSD.org/ I am not sure if this will fix your problem, but there is a global option ShowShortBoxForm, which I always set to False. In that state, notebooks are written with normal RowBox notation rather than using the backslash notation for everything. If you are going to read the notebooks with anything other than Mathematica (which you are) this is a great help. I don't suppose notebooks were really designed with revision control in mind. I don't know if anyone has explored the idea at all, but I think there are a lot of issues here. For example, if you are going to run difference comparisons between different versions of a notebook, that is going to be really hard to read! Perhaps there is a project for someone here! David Bailey dbaileyconsultancy.co.uk === Subject: Re: Why does mathematica randomly rewrite notebooks? Internally, we use CVS on notebooks, so making notebooks function well with revision control systems is an important goal to us. CVS generally works fine on notebooks, with the caveat of avoiding the keyword expansion features, and the sometimes-difficult-to-interpret diffs. Unfortunately, revision control diffing tools really like to assume that all documents are basically unstructured text documents, while notebooks do have structure which is hard to visualize in text-diffs and are freely line-wrapped by the FE in such a way that can sometimes really defeat a straight text diff. Also, the file outline caches (the comments at the end of the file used to make speedy incremental loading of notebook possible) can change frequently and pollute the diffs with information that's never useful to see. In fact, this isn't anything unique to notebooks. Any structured document format...XML is a perfect and ubiquitous example...is not as interesting when diffs are viewed textually as it is when diffs are viewed with a diffing tool that understands the structure. We do have such a structural diffing tool. Check out the NotebookDiff function in the AuthorTools` package. This function requires the two versions of the notebooks side-by-side on your file system, but can be invaluable at understanding what the heck a diff actually means. We often use it internally to help with our document management. There are also a couple of bugs which do needlessly rewrite sections of the the notebook which will be fixed in future versions (the notebooks written out are correct notebooks...but the variations are not strictly necessary). Additionally, we've done some work for future versions to allow cvs keyword expansion without throwing off the file outline cache and to allow complete suppression of file outline caches by default. We continue to look into other means of making revision control of notebooks easier. Also, let me correct point 1 below, which is precisely incorrect. CVS has no practical line limit, and Mathematica notebook files as written by the FE are uniformly 78 characters or less in length (this isn't a requirement of the notebook format, just a convention enforced by the FE). John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. > A few remarks : > 1 - CVS is line oriented, and lines MUST be less than 80 characters > long, while Mathematica notebooks make no assumptions on line length. > This might explain the changes you have noticed. > 2 - Mathematica uses a cache, handling this cache in a versioning system > can be viewed as non-sense. The company Analog Insydes discusses this > point and provides a set of utilities for handling notebooks with CVS : > http://www.analog-insydes.de/ai/utilities/ I have used these utilities > up to version 5.0 without trouble of any kind. > 3 - When notebooks contain some information that can be modified by the > versioning system, the FrontEnd will report a warning. If this warning > can oftenly be ignored, users might nevertheless have some doubt about > the versioning strategy, and there is no way to avoid this with CVS. > 4 - After using CVS for some years, I switched to subversion. This > system is much more adequate for revision control than CVS is, > especially for files like mathematica notebooks. I do not modify the > notebooks before storing them in the repository (meaning I do NOT strip > the cache off, even if this can be viewed as a loss of disk resource), > because disk space is no longer a problem and because Mathematica > projects seldom span over hundreds of files. If I have no experience in > migrating a project from CVS to subversion, all new projects are now > handled by subversion. > jmt >> I'm trying to manage mathematica notebooks in a revision control system >> trivial changes seemingly randomly. Does anyone know why? >> Here's an example: >> @@ -860,7 +862,7 @@ >> (Tuu[i, j] Xd[j] // ToFlavor[natbasis]), n, >> (((% /. >> x : Xd[_] [RuleDelayed] (TransformIndexFlavor[ >> - natbasis, >> {[Lambda]form}])[x])(n)([IndentingNewLine]) + >> natbasis, {[Lambda]form}])[x])([IndentingNewLine])(n) ) >> (*[IndentingNewLine](% // SumExpansion[natbasis /@ {i, j}]) // >> SumExpansion[[Lambda]form[k]][IndentingNewLine]%%[IndentingNewLine]* >> ) >> ), >> The line starting with '-' shows what was there, and the line starting >> with '+' shows that change that mathematica made at the last save. >> Notice the at the order of the n and the IndentingNewLine have been >> reversed. This appears to happen at random. >> WRI, is there anything I can do to prevent this, or is it a >> bug/feature? >> Joe >> -- >> Josef Karthauser (joe@tao.org.uk) http://www.josef-k.net/ >> FreeBSD (cvs meister, admin and hacker) http://www.uk.FreeBSD.org/ === Subject: Re: Front End Programming question > I am looking at John M. Novak presentation he did at the 1999 > Mathematica Developers's Conference, titled Front End Programming. > Based upon his notebook, I ask input questions the following way. > First I define two functions, askForInput and dialogForInput. > askForInput[inputLabel_: > ] := Module[{thenb, > result}, > thenb = dialogForInput[ > inputLabel]; > While[Options[thenb, > {Visible -> True}, > Do[Null, {250}]]; > NotebookFind[thenb, > TheInput, All, > CellTags]; result = > NotebookRead[thenb]; > NotebookClose[thenb]; > MakeExpression[result[[1, > 1]]]] > dialogForInput[ > inputLabel_] := > NotebookPut[Notebook[ > {Cell[BoxData[StringJoin[ > inputLabel, ]], > Input, CellFrame -> > True, Evaluatable -> > False, > ShowCellTags -> True, > CellTags -> > TheInput, > CellMargins -> > {{10, 10}, {4, 4}}, > Deletable -> False], > Cell[BoxData[ > ButtonBox[OK, > RuleDelayed[Butto > nFunction, > SetOptions[Butt > onNotebook[], > Rule[Visible, > False]]], > Rule[ButtonFrame, > DialogBox]] > ], Input, > Editable -> False, > Active -> True, > TextAlignment -> > Center, > CellMargins -> > {{10, 10}, {20, > 2}}]}, > ShowCellBracket -> > False, WindowFrame -> > MovableModalDialog, > WindowFloating -> False, > WindowSize -> {300, > 150}, > WindowFrameElements -> > {}, WindowElements -> > { > VerticalScrollBar}]] > Then if I want to ask a question I call askForInput and grab the value > with the Nest: > primerLength = ReleaseHold[ > askForInput[ > Length of a Primer:]]; > primerLength = Nest[Last, > primerLength, > Depth[primerLength] - 1]; > If I want to ask another question I do the same thing with a different > question into another variable, like: > averagePrimerDistance = > ReleaseHold[askForInput[ > Average Primer > Distance:]]; > averagePrimerDistance = > Nest[Last, > averagePrimerDistance, > Depth[ > averagePrimerDistance] > - 1]; > Works great, - one question at a time. My question is, how can I > present multiple questions into one dialog and sort out the answers > after the values are typed in and the button is clicked. I tried > a number of different ways, - making inputLabel a List, creating a > table of Cells with different CellTags, getting the results back into > an array, played with GUIKit, etc... - but did not find the right one. > All failed at the NotebookFind[thenb, TheInput, All, CellTags]; > command and its variants. Conceptually the question looks easy, but > the devil is - always - in the implementation :) > J.87nos > ---------------------------------------------- > Trying to argue with a politician is like lifting up the head of a > corpse. > (S. Lem: His Master Voice) I found GUIKit to be very comprehensive, but extremely hard to use! As a freely available at my site. This package uses GUIKit, but lets you build a typical GUI in an almost trivial way, and everything works in a 'traditional' Mathematica way - for example, you specify colours with RGBColor notation, not as Widget[class:java.awt.Color, InitialArguments -> {255,0,0}] free to email me about it. David Bailey dbaileyconsultancy.co.uk === Subject: Re: repeating elements in a list lst={A,B,C}; n=3; newlst=Flatten[Table[#,{n}]&/@lst] {A,A,A,B,B,B,C,C,C} Bob Hanlon === > Subject: repeating elements in a list > suppose I have list > lst={A, B, C} > and I want to create a new list, where all elements are repeated n times > so that (for n=3): > newlst={A, A, A, B, B, B, C, C, C} > I have the following code to do this: > n=3; > newlst=Flatten[Table[Table[lst[[i]], {n}], {i, Length[lst]}]]; > but I'm pretty sure, that there must be a more elegant way to solve the > problem. > thank you === Subject: Re: Setting the ResultFormat in a ASP.NET WebApplication. >The ResultFormat of the MathKernel is set to OutputForm as default, and I >would like to set it to other ResultFormatTypes, like StandardForm or >MathML. How can I do this? It says that I cannot convert a string to >'Wolfram.NETLink.MathKernel.ResultFormatType' when I do like this: >Global.mathKernel.ResultFormat = StandardForm; >or like this: >Global.mathKernel.ResultFormat = >(Wolfram.NETLink.MathKernel.ResultFormatType) StandardForm; >How can I set the ResultFormat then? Javier, ResultFormatType is an enum, so you use its values like this: Global.mathKernel.ResultFormat = MathKernel.ResultFormatType.StandardForm; Todd Gayley Wolfram Research === Subject: Re: defining a recursive formula? > can someone help me represent the following? > i have a quantity p[R_] := i* R -a > i need to compute > F[N_] := p[p[p[p[p[R]]]]] to N levels deep. > lou Lou, you can use: pn = Nest[i*#1 - a & , #1, #2]&; In[2]:=pn[R, 10] Out[2]=-a + i*(-a + i*(-a + i*(-a + i*(-a + i*(-a + i*(-a + i*(-a + i*(-a + i*(-a + i*R))))))))) but for larger values of n this becomes tedious. I suggest the use of pn2 = Evaluate[p /. First[RSolve[{p[n + 1] == i*p[n] - a, p[0] == #1}, p, n]]]&; In[4]:=pn2[x][10] Out[4]=(a - a*i^10 - i^10*x + i^11*x)/(-1 + i) Of course pn2 is much faster than pn: In[5]:= First[Timing[y1 = pn[R, 1000]; ]] Out[5]= 0.25 Second In[6]:= First[Timing[y2 = pn2[R][1000]; ]] Out[6]= 0. Second Expanding y1 lasts a while... In[7]:= Timing[Simplify[y1 == y2]] Out[7]= {5.719*Second, True} and further work with these expressions reveals even greater differences in calculation time: In[8]:= First /@ (Timing[D[#1, i]; ] & ) /@ {y1, y2} Out[8]= {44.563 Second, 0. Second} It's your choice... -- Peter Pein Berlin === Subject: Re: Help Mathematica > How i can obtain a list {x1_,x2_,x3_} from a list {x1, x2, x3}... > thank you for help and sorry for my bad english...i'm italian Pattern[#,Blank[]]&/@{x1,x2,x3} -- Peter Pein Berlin === Subject: Re: Help Mathematica > How i can obtain a list {x1_,x2_,x3_} from a list {x1, x2, x3}... > thank you for help and sorry for my bad english...i'm italian The clue is to look at x1_//Fullform - if you do that, it is obvious that what you need is: Map[Pattern[#, Blank[]] &, {x1, x2, x3}] David Bailey dbaileyconsultancy.co.uk === Subject: Re: repeating elements in a list >suppose I have list >lst={A, B, C} >and I want to create a new list, where all elements are repeated n >times so that (for n=3): >newlst={A, A, A, B, B, B, C, C, C} >I have the following code to do this: >n=3; newlst=Flatten[Table[Table[lst[[i]], {n}], {i, Length[lst]}]]; >but I'm pretty sure, that there must be a more elegant way to solve >the problem. Elegance is mostly in the eye of the beholder. But another way to achieve what you want would be Flatten@Transpose[Flatten /@ NestList[List, lst, 2]] -- To reply via email subtract one hundred and four === Subject: Re: How to match/balance parenthesis? >will help me determine which set of parenthesis, curly braces, or >brackets they belong to in a mathematica v 5.0.1.0 notebook. (e.g. >{{{ }}}). Is there such a feature, and if so how do I get I am not entirely sure what you want, but perhaps the menu Edit->Check Balance will do the trick. Simply click some where in the expression and select this menu item or use cmd-shft-B (for Mac OS X) and Mathematica will highlight the portion contained by curly braces etc. Repeated application will extend the highlighted section to the next level of curly braces etc. -- To reply via email subtract one hundred and four === Subject: Re: repeating elements in a list lst = {A, B, C} repeatn[n_] := Sequence @@ Table[#, {n}] & repeatn[3] /@ lst {A, A, A, B, B, B, C, C, C} David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ suppose I have list lst={A, B, C} and I want to create a new list, where all elements are repeated n times so that (for n=3): newlst={A, A, A, B, B, B, C, C, C} I have the following code to do this: n=3; newlst=Flatten[Table[Table[lst[[i]], {n}], {i, Length[lst]}]]; but I'm pretty sure, that there must be a more elegant way to solve the problem. thank you === Subject: Re: Kernel Problem Dana, Shuts down my kernel also on Version 5.0.1, Windows98. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ Hello. I'd like to ask a question. The function below shuts down my Kernel. Is it just me, or is this reproducible on other Windows machines. Needs[NumberTheory`NumberTheoryFunctions`] Information[QuadraticRepresentation] QuadraticRepresentation[d, n] gives {x, y}, where x^2 + d y^2 = n for positive d and odd n. QuadraticRepresentation[12, 9] (Problem, and the Kernel shuts down!) TIA Dana DeLouis === Subject: Re: Re: help browser cells inactive? Yes; in fact, I always run as Administrator. I did manage a cure by restarting with defaults (holding down SHIFT-CONTROL when starting Mathematica). What I am a loss to understand is what might have caused the unexpected behavior in the first place. >>In the Help Browser for Mathematica 5.1.1 (under Windows 5.1.1), all >>input cells seem to be inactive... >> (1) I cannot edit or evaluate any input cell in the HelpBrowser; >> (2) I cannot copy a cell, or any selected expression in a cell, from >>the HelpBrowser to another notebook; > Did you try with full administrative rights? -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Kernel Problem Same thing here, using Windows XP Professional (SP2) and: $Version 5.1 for Microsoft Windows (January 27, 2005) (Actually, version 5.1.1.0.) > Hello. I'd like to ask a question. The function below shuts down my > Kernel. Is it just me, or is this reproducible on other Windows machines. > Needs[NumberTheory`NumberTheoryFunctions`] > Information[QuadraticRepresentation] > QuadraticRepresentation[d, n] gives {x, y}, where x^2 + d y^2 = n for > positive d and odd n. > QuadraticRepresentation[12, 9] > (Problem, and the Kernel shuts down!) > TIA > Dana DeLouis -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Kernel Problem This feature also works with [12,3] My info: On Sat, 5 Mar 2005 01:34:25 -0500 (EST), Dana DeLouis > Hello. I'd like to ask a question. The function below shuts down my > Kernel. Is it just me, or is this reproducible on other Windows machines. > Needs[NumberTheory`NumberTheoryFunctions`] > Information[QuadraticRepresentation] > QuadraticRepresentation[d, n] gives {x, y}, where x^2 + d y^2 = n for > positive d and odd n. > QuadraticRepresentation[12, 9] > (Problem, and the Kernel shuts down!) > TIA > Dana DeLouis -- Chris Chiasson Kettering University Mechanical Engineering Graduate Student 1 810 265 3161 === Subject: Re: Re: Bug in Import? to which Mathematica wiki site do you refer? to http://en.wikipedia.org/wiki/Mathematica? I've also found Mathematica wikis at: http://wiki.cs.brynmawr.edu/?page=GLUE https://engineering.purdue.edu/ECN/News/mathematica_wiki (this requires a logon name and password, but no obvious way to get one that I could see) > It seems like a lot of confusion happens because things are > undocumented or, more frequently, because people can't find the right > documentation in Mathematica help. Maybe we could add a documentation > section to that Mathematica wiki site? -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Re: Bug in Import? In[1]:= Export[test.tsv, {{2005-01-24, 2005-02-14}, {2005-01-24, 2005-02-14}}] Out[1]= test.tsv In[2]:= Import[test.tsv, ConversionOptions -> {Numeric -> False, Out[2]= {{2005-01-24, 2005-02-14}, {2005-01-24, 2005-02-14}} In[3]:= Import[test.tsv] Out[3]= {{2005-01-24, 2005-02-14}, {2005, -1, -24, 2005, -2, -14}} In[4]:= Import[test.tsv, ConversionOptions -> {NumberSigns -> {^, *}}] Out[4]= {{2005-01-24, 2005-02-14}, {2005-01-24, 2005-02-14}} In[5]:= $Version Window XP Profesional The format for Import is Import[test.tsv, TSV, Encoding -> None, ConversionOptions -> {...}] That is hard to find in the Help files. Still does not explain why the second line gets messed up. Is it the record separator, is it the number sign Hans No problems in Version 5.0 In[1]:= Export[test.tsv, {{2005-01-24, 2005-02-14}, {2005-01-24, 2005-02-14}}] Out[1]= test.tsv In[2]:= Out[2]= {{2005-01-24, 2005-02-14}, {2005-01-24, 2005-02-14}} In[3]:= Import[test.tsv] Out[3]= {{2005-01-24, 2005-02-14}, {2005-01-24, 2005-02-14}} In[4]:= $Version Out[4]= > Not well indexed? That's putting it mildly. > Here's an example of use (MUCH needed in Help): > Export[test.tsv, > {{2005-01-24, 2005-02-14}, > {2005-01-24, 2005-02-14}}] > Import[test.tsv, > ConversionOptions -> {Numeric -> > No matter what options are used, however... > Why is the second record converted differently than the first? > Bobby > On Wed, 2 Mar 2005 22:29:21 -0500 (EST), Hans Michel >> Mark: >> Late 2 cents: >> As in the Help File Under Import >> NumberSigns, Numeric} >> for TVS and Table formats will impact the conversion of your data file. >> Not well indexed not even an example of use. >> Hans > (1) I export a data set that has two identitcal rows. > (2) I use !! to display the stored file, showing that it contains two > identical rows. > (3) I import the file, the result of which does *not* have two identical > rows: The first row is different from the second row. > Export[test.tsv, > {{2005-01-24, 2005-02-14}, > { 2005-01-24, 2005-02-14}}] > !!test.tsv --> > 2005-01-24 2005-02-14 > 2005-01-24 2005-02-14 > Import[test.tsv] --> > {{2005-01-24, 2005-02-14}, > {2005, -1, -24, 2005, -2, -14}} > Surely this is a bug. > (I sent this example to support@wolfram.com three weeks ago, but the > only response I've received is that it's not a bug. Frankly, I don't > think the tech person who responded understood the example.) > I am using version 5.1 for Windows. > --Mark. > -- > DrBob@bigfoot.com > www.eclecticdreams.net === Subject: where is DrBob's web site? What might the current URL be for DrBob's web site that used to be at eclecticdreams.net? -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Rearranging a data array containing calendrical as well as data entries. Ah! You're right, but the fix is simple. I thought each line had up to 7 data values (a week per line), but actually they have up to 8. Careless of me not to count them! Change 7 to 8 in dateValue, and that takes care of it. If the (max) table width is variable, on the other hand, we'd need different code. Bobby > Does not match. > January has 31 days. > The USGS data is well ordered. > Hans >> Here's a start: >> rawData=Import[test.txt,Table] > {{1999,1,1,489.82,489.82,495.01,495.01,495.01,495.01,495.01,490.51},{199 > 9,1,2, >> 490.51,490.51,490.51,490.51,490.38,490.38,490.38,490.38},{ > 1999,1,3,490.38,510.38,510.38,510.38,510.38,510.38,528.66,528.66},{1999, > 1,4, >> 528.66,528.66,528.66,501.68,501.68,501.68,501.68},{1999,2, > 1,501.68,496.44,496.44,496.44,496.44,496.44,478.72,478.72},{1999,2,2,478 > .72, >> 478.72,478.72,452.82,452.82,452.82,452.82,452.82},{1999,2, > 3,450.19,450.19,450.19,450.19,450.19,443.98,443.98,443.98},{1999,2,4,443 > .98, >> 443.98,440.14,440.14},{1999,3,1,440.14,440.14,440.14,453.64, > 453.64,453.64,453.64,453.64},{1999,3,2,503.98,503.98,503.98,503.98,503.9 > 8, >> 500.84,500.84,500.84},{1999,3,3,500.84,500.84,473.48,473.48, > 473.48,473.48,473.48,463.19},{1999,3,4,463.19,463.19,463.19,463.19,457.5 > 4, >> 457.54,457.54}} >> Clear[dateValue, month, twoDigit] >> twoDigit[i_Integer?Positive] := StringJoin @@ >> PadLeft[Characters@ToString@i, 2, 0] >> month[i_Integer] /; 1 <= i <= 12 := month[i] = {Jan, Feb, Mar, >> Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec}[[i]] >> dateValue@{yr_, mo_, wk_, values___} := Transpose@{twoDigit[# + 7( >> wk - 1)] <> month@mo <> ToString@yr & /@ Range@Length@{values}, >> {values}} >> Flatten[dateValue /@ rawData, 1] >> {{01Jan1999, 489.82}, >> {02Jan1999, 489.82}, >> {03Jan1999, 495.01}, >> {04Jan1999, 495.01}, >> {05Jan1999, 495.01}, >> {06Jan1999, 495.01}, >> {07Jan1999, 495.01}, >> {08Jan1999, 490.51}, >> {08Jan1999, 490.51}, >> {09Jan1999, 490.51}, >> {10Jan1999, 490.51}, >> {11Jan1999, 490.51}, >> {12Jan1999, 490.38}, >> {13Jan1999, 490.38}, >> {14Jan1999, 490.38}, >> {15Jan1999, 490.38}, >> {15Jan1999, 490.38}, >> {16Jan1999, 510.38}, >> {17Jan1999, 510.38}, >> {18Jan1999, 510.38}, >> {19Jan1999, 510.38}, >> {20Jan1999, 510.38}, >> {21Jan1999, 528.66}, >> {22Jan1999, 528.66}, >> {22Jan1999, 528.66}, >> {23Jan1999, 528.66}, >> {24Jan1999, 528.66}, >> {25Jan1999, 501.68}, >> {26Jan1999, 501.68}, >> {27Jan1999, 501.68}, >> {28Jan1999, 501.68}, >> {01Feb1999, 501.68}, >> {02Feb1999, 496.44}, >> {03Feb1999, 496.44}, >> {04Feb1999, 496.44}, >> {05Feb1999, 496.44}, >> {06Feb1999, 496.44}, >> {07Feb1999, 478.72}, >> {08Feb1999, 478.72}, >> {08Feb1999, 478.72}, >> {09Feb1999, 478.72}, >> {10Feb1999, 478.72}, >> {11Feb1999, 452.82}, >> {12Feb1999, 452.82}, >> {13Feb1999, 452.82}, >> {14Feb1999, 452.82}, >> {15Feb1999, 452.82}, >> {15Feb1999, 450.19}, >> {16Feb1999, 450.19}, >> {17Feb1999, 450.19}, >> {18Feb1999, 450.19}, >> {19Feb1999, 450.19}, >> {20Feb1999, 443.98}, >> {21Feb1999, 443.98}, >> {22Feb1999, 443.98}, >> {22Feb1999, 443.98}, >> {23Feb1999, 443.98}, >> {24Feb1999, 440.14}, >> {25Feb1999, 440.14}, >> {01Mar1999, 440.14}, >> {02Mar1999, 440.14}, >> {03Mar1999, 440.14}, >> {04Mar1999, 453.64}, >> {05Mar1999, 453.64}, >> {06Mar1999, 453.64}, >> {07Mar1999, 453.64}, >> {08Mar1999, 453.64}, >> {08Mar1999, 503.98}, >> {09Mar1999, 503.98}, >> {10Mar1999, 503.98}, >> {11Mar1999, 503.98}, >> {12Mar1999, 503.98}, >> {13Mar1999, 500.84}, >> {14Mar1999, 500.84}, >> {15Mar1999, 500.84}, >> {15Mar1999, 500.84}, >> {16Mar1999, 500.84}, >> {17Mar1999, 473.48}, >> {18Mar1999, 473.48}, >> {19Mar1999, 473.48}, >> {20Mar1999, 473.48}, >> {21Mar1999, 473.48}, >> {22Mar1999, 463.19}, >> {22Mar1999, 463.19}, >> {23Mar1999, 463.19}, >> {24Mar1999, 463.19}, >> {25Mar1999, 463.19}, >> {26Mar1999, 457.54}, >> {27Mar1999, 457.54}, >> {28Mar1999, 457.54}} >> Bobby >> On Wed, 2 Mar 2005 22:29:16 -0500 (EST), Gilmar > I have a file containing flow data from the USGS, in the following > format: > 1999 1 1 489.82 489.82 495.01 495.01 495.01 495.01 495.01 490.51 > 1999 1 2 490.51 490.51 490.51 490.51 490.38 490.38 490.38 490.38 > 1999 1 3 490.38 510.38 510.38 510.38 510.38 510.38 528.66 528.66 > 1999 1 4 528.66 528.66 528.66 501.68 501.68 501.68 501.68 > 1999 2 1 501.68 496.44 496.44 496.44 496.44 496.44 478.72 478.72 > 1999 2 2 478.72 478.72 478.72 452.82 452.82 452.82 452.82 452.82 > 1999 2 3 450.19 450.19 450.19 450.19 450.19 443.98 443.98 443.98 > 1999 2 4 443.98 443.98 440.14 440.14 > 1999 3 1 440.14 440.14 440.14 453.64 453.64 453.64 453.64 453.64 > 1999 3 2 503.98 503.98 503.98 503.98 503.98 500.84 500.84 500.84 > 1999 3 3 500.84 500.84 473.48 473.48 473.48 473.48 473.48 463.19 > 1999 3 4 463.19 463.19 463.19 463.19 457.54 457.54 457.54 > This format is used by the USGS to compress their data records. > Each row contains: > Year, Month Number(1 to 12), Row Number (1 to 4), and data entries. > The first row: > 1999 1 1 489.82 489.82 495.01 495.01 495.01 495.01 495.01 490.51 > contains flow values corresponding to: January 1 to January 8, > of the year 1999. > The second row: > 1999 1 2 490.51 490.51 490.51 490.51 490.38 490.38 490.38 490.38 > contains flow values corresponding to: January 9 to January 16, > of the year 1999. > The third row: > 1999 1 3 490.38 510.38 510.38 510.38 510.38 510.38 528.66 528.66 > contains flow values corresponding to: January 17 to January 24, > of the year 1999. > The fourth row: > 1999 1 4 528.66 528.66 528.66 501.68 501.68 501.68 501.68 > contains flow values corresponding to: January 25 to January 31, > of the year 1999. > I think that you get the picture of how this data set is assembled. > What I need is a program that can turn the above mentioned horizontal > array, into a simple vertical array, containing two columns; > the first column contains the dates when the data was collected, > and the second column contains the flow values; i.e. > 01Jan1999 489.82 > 02Jan1999 489.82 > 03Jan1999 495.01 > etc. > If I give the program a starting date, and ending date for an > arbitrary record; the program should be able to allocate two > arrays to: > (1.) put the dates between the starting date, and ending date, > to form the first column of the vertical array. > (2.)match correctly those dates with the data to appear in > the second column of the vertical array. > The program should discern between regular years, and leap > years. Those of you that are still using FORTRAN, and have > experienced how difficult it is to deal with date functions > using FORTRAN, might sympathize with my request. > P.S. To get a larger set of USGS flow data to test your program > please download the following file: > http://www.gilmarlily.netfirms.com/download/flow.dat >> -- >> DrBob@bigfoot.com >> www.eclecticdreams.net -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: Rearranging a data array containing calendrical as well as data entries. Does not match. January has 31 days. The USGS data is well ordered. Hans > Here's a start: > rawData=Import[test.txt,Table] > {{1999,1,1,489.82,489.82,495.01,495.01,495.01,495.01,495.01,490.51},{1999,1,2 , > 490.51,490.51,490.51,490.51,490.38,490.38,490.38,490.38},{ > 1999,1,3,490.38,510.38,510.38,510.38,510.38,510.38,528.66,528.66},{1999,1,4, > 528.66,528.66,528.66,501.68,501.68,501.68,501.68},{1999,2, > 1,501.68,496.44,496.44,496.44,496.44,496.44,478.72,478.72},{1999,2,2,478.72, > 478.72,478.72,452.82,452.82,452.82,452.82,452.82},{1999,2, > 3,450.19,450.19,450.19,450.19,450.19,443.98,443.98,443.98},{1999,2,4,443.98, > 443.98,440.14,440.14},{1999,3,1,440.14,440.14,440.14,453.64, > 453.64,453.64,453.64,453.64},{1999,3,2,503.98,503.98,503.98,503.98,503.98, > 500.84,500.84,500.84},{1999,3,3,500.84,500.84,473.48,473.48, > 473.48,473.48,473.48,463.19},{1999,3,4,463.19,463.19,463.19,463.19,457.54, > 457.54,457.54}} > Clear[dateValue, month, twoDigit] > twoDigit[i_Integer?Positive] := StringJoin @@ > PadLeft[Characters@ToString@i, 2, 0] > month[i_Integer] /; 1 <= i <= 12 := month[i] = {Jan, Feb, Mar, > Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec}[[i]] > dateValue@{yr_, mo_, wk_, values___} := Transpose@{twoDigit[# + 7( > wk - 1)] <> month@mo <> ToString@yr & /@ Range@Length@{values}, > {values}} > Flatten[dateValue /@ rawData, 1] > {{01Jan1999, 489.82}, > {02Jan1999, 489.82}, > {03Jan1999, 495.01}, > {04Jan1999, 495.01}, > {05Jan1999, 495.01}, > {06Jan1999, 495.01}, > {07Jan1999, 495.01}, > {08Jan1999, 490.51}, > {08Jan1999, 490.51}, > {09Jan1999, 490.51}, > {10Jan1999, 490.51}, > {11Jan1999, 490.51}, > {12Jan1999, 490.38}, > {13Jan1999, 490.38}, > {14Jan1999, 490.38}, > {15Jan1999, 490.38}, > {15Jan1999, 490.38}, > {16Jan1999, 510.38}, > {17Jan1999, 510.38}, > {18Jan1999, 510.38}, > {19Jan1999, 510.38}, > {20Jan1999, 510.38}, > {21Jan1999, 528.66}, > {22Jan1999, 528.66}, > {22Jan1999, 528.66}, > {23Jan1999, 528.66}, > {24Jan1999, 528.66}, > {25Jan1999, 501.68}, > {26Jan1999, 501.68}, > {27Jan1999, 501.68}, > {28Jan1999, 501.68}, > {01Feb1999, 501.68}, > {02Feb1999, 496.44}, > {03Feb1999, 496.44}, > {04Feb1999, 496.44}, > {05Feb1999, 496.44}, > {06Feb1999, 496.44}, > {07Feb1999, 478.72}, > {08Feb1999, 478.72}, > {08Feb1999, 478.72}, > {09Feb1999, 478.72}, > {10Feb1999, 478.72}, > {11Feb1999, 452.82}, > {12Feb1999, 452.82}, > {13Feb1999, 452.82}, > {14Feb1999, 452.82}, > {15Feb1999, 452.82}, > {15Feb1999, 450.19}, > {16Feb1999, 450.19}, > {17Feb1999, 450.19}, > {18Feb1999, 450.19}, > {19Feb1999, 450.19}, > {20Feb1999, 443.98}, > {21Feb1999, 443.98}, > {22Feb1999, 443.98}, > {22Feb1999, 443.98}, > {23Feb1999, 443.98}, > {24Feb1999, 440.14}, > {25Feb1999, 440.14}, > {01Mar1999, 440.14}, > {02Mar1999, 440.14}, > {03Mar1999, 440.14}, > {04Mar1999, 453.64}, > {05Mar1999, 453.64}, > {06Mar1999, 453.64}, > {07Mar1999, 453.64}, > {08Mar1999, 453.64}, > {08Mar1999, 503.98}, > {09Mar1999, 503.98}, > {10Mar1999, 503.98}, > {11Mar1999, 503.98}, > {12Mar1999, 503.98}, > {13Mar1999, 500.84}, > {14Mar1999, 500.84}, > {15Mar1999, 500.84}, > {15Mar1999, 500.84}, > {16Mar1999, 500.84}, > {17Mar1999, 473.48}, > {18Mar1999, 473.48}, > {19Mar1999, 473.48}, > {20Mar1999, 473.48}, > {21Mar1999, 473.48}, > {22Mar1999, 463.19}, > {22Mar1999, 463.19}, > {23Mar1999, 463.19}, > {24Mar1999, 463.19}, > {25Mar1999, 463.19}, > {26Mar1999, 457.54}, > {27Mar1999, 457.54}, > {28Mar1999, 457.54}} > Bobby > On Wed, 2 Mar 2005 22:29:16 -0500 (EST), Gilmar >> I have a file containing flow data from the USGS, in the following >> format: >> 1999 1 1 489.82 489.82 495.01 495.01 495.01 495.01 495.01 490.51 >> 1999 1 2 490.51 490.51 490.51 490.51 490.38 490.38 490.38 490.38 >> 1999 1 3 490.38 510.38 510.38 510.38 510.38 510.38 528.66 528.66 >> 1999 1 4 528.66 528.66 528.66 501.68 501.68 501.68 501.68 >> 1999 2 1 501.68 496.44 496.44 496.44 496.44 496.44 478.72 478.72 >> 1999 2 2 478.72 478.72 478.72 452.82 452.82 452.82 452.82 452.82 >> 1999 2 3 450.19 450.19 450.19 450.19 450.19 443.98 443.98 443.98 >> 1999 2 4 443.98 443.98 440.14 440.14 >> 1999 3 1 440.14 440.14 440.14 453.64 453.64 453.64 453.64 453.64 >> 1999 3 2 503.98 503.98 503.98 503.98 503.98 500.84 500.84 500.84 >> 1999 3 3 500.84 500.84 473.48 473.48 473.48 473.48 473.48 463.19 >> 1999 3 4 463.19 463.19 463.19 463.19 457.54 457.54 457.54 >> This format is used by the USGS to compress their data records. >> Each row contains: >> Year, Month Number(1 to 12), Row Number (1 to 4), and data entries. >> The first row: >> 1999 1 1 489.82 489.82 495.01 495.01 495.01 495.01 495.01 490.51 >> contains flow values corresponding to: January 1 to January 8, >> of the year 1999. >> The second row: >> 1999 1 2 490.51 490.51 490.51 490.51 490.38 490.38 490.38 490.38 >> contains flow values corresponding to: January 9 to January 16, >> of the year 1999. >> The third row: >> 1999 1 3 490.38 510.38 510.38 510.38 510.38 510.38 528.66 528.66 >> contains flow values corresponding to: January 17 to January 24, >> of the year 1999. >> The fourth row: >> 1999 1 4 528.66 528.66 528.66 501.68 501.68 501.68 501.68 >> contains flow values corresponding to: January 25 to January 31, >> of the year 1999. >> I think that you get the picture of how this data set is assembled. >> What I need is a program that can turn the above mentioned horizontal >> array, into a simple vertical array, containing two columns; >> the first column contains the dates when the data was collected, >> and the second column contains the flow values; i.e. >> 01Jan1999 489.82 >> 02Jan1999 489.82 >> 03Jan1999 495.01 >> etc. >> If I give the program a starting date, and ending date for an >> arbitrary record; the program should be able to allocate two >> arrays to: >> (1.) put the dates between the starting date, and ending date, >> to form the first column of the vertical array. >> (2.)match correctly those dates with the data to appear in >> the second column of the vertical array. >> The program should discern between regular years, and leap >> years. Those of you that are still using FORTRAN, and have >> experienced how difficult it is to deal with date functions >> using FORTRAN, might sympathize with my request. >> P.S. To get a larger set of USGS flow data to test your program >> please download the following file: >> http://www.gilmarlily.netfirms.com/download/flow.dat > -- > DrBob@bigfoot.com > www.eclecticdreams.net === Subject: Re: Re: Help Mathematica Here are two ways to do it: Pattern[#,Blank[]]&/@{x1,x2,x3} {x1_,x2_,x3_} ToExpression[ToString[#]<>_&/@{x1,x2,x3}] {x1_,x2_,x3_} Bobby >> How i can obtain a list {x1_,x2_,x3_} from a list {x1, x2, x3}... > You can't. The '_' character is a special purpose character in Mathematica and cannot be used as part of a symbol name. > Of course you could do something like ToString[#]<>_&/@{x1, x2, x3}. But I doubt having a list of strings is what you want. > If you indicated what your overall goal is, I or someone else here might be able to suggest a solution to the problem. > -- > To reply via email subtract one hundred and four -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: Help Mathematica In[1]:= lst={x1,x2,x3}; In[2]:= params=Pattern[#,Blank[]]&/@lst; In[3]:= f[params]=Plus@@lst; In[4]:= f[{1,2,3}] Out[4]= 6 Mitch Stonehocker -----Original Message----- === Subject: Help Mathematica Map[Pattern[#,Blank[]]&,{x1,x2,x3}] {x1_,x2_,x3_} Pattern[#,Blank[]]&/@{x1,x2,x3} {x1_,x2_,x3_} #_&/@{x1,x2,x3} {x1 _,x2 _,x3 _} Bob Hanlon === > Subject: Help Mathematica > How i can obtain a list {x1_,x2_,x3_} from a list {x1, x2, x3}... > thank you for help and sorry for my bad english...i'm italian === Subject: Re: Re: Goto Line ? >> If you've got the file opened, why don't you edit it immediatelly??? Because it's not always trivial editing package (.m) files -- if the package includes a lot of special symbols, for instance. Some people edit their packages in text editors (I gather), but I never would. Bobby > I hope I don't blame me too much ... > In my package is an error. Line 466: missing ... or so. >> It was a Warning ... > How Do I go to Line 466 in Mathematica 4.2? >> So far i loaded the File in emacs went to Line 466 >> and saw what was there. >> Then going to the same point with the editor of >> Mathematica ... >> I'm sure there is an easier way :) >> Detlef > AFAIK emacs is capable of changing the contents of a text file > (understatement of the year) ?!? > If you've got the file opened, why don't you edit it immediatelly??? > I'm sure, you have got good reasons, but I've got an > severe imagination error [Cancel][Continue][Help]. ;-) -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: Re: Goto Line ? It is only inconsistent to the extent that it is inconsistent for WRI to develop a package format for Mathematica and provide no tools for editing or handling of packages (besides a basic template). The FrontEnd has tools only for manipulating notebooks and the concept of line is not appropriate in a Mathematica notebook. On the other this is an opportunity for someone else to develop such tools. For example, on the Mac someone familiar with Tcl could develop a Mathematica package mode for the AlphaX editor (or using Tk instead of TCl one could do this for AlphaTk which also runs on Windows). Andrzej Kozlowski > This seems a bit inconsistent for Wolfram to indicate a cryptic error > at > some specific line #, but to then fail to have a way within > Mathematica itself > to correct the problem. Yeah, I know, it will be fixed in a future > release. > Kevin > In my package is an error. Line 466: missing ... or so. > How Do I go to Line 466 in Mathematica 4.2? >> In Mathematica, I don't know. But if you open your package as a text >> file in a text >> editor such as PFE, KWrite or EditPad (they are all free) you can do >> that in >> a jiffy. >> cheers, >> Peltio === Subject: Re: Goto Line ? >>I hope I don't blame me too much ... >>In my package is an error. Line 466: missing ... or so. > It was a Warning ... >>How Do I go to Line 466 in Mathematica 4.2? > So far i loaded the File in emacs went to Line 466 > and saw what was there. > Then going to the same point with the editor of > Mathematica ... > I'm sure there is an easier way :) > Detlef The easy way is to develop your code as a notebook and then use the AutogeneratedPackage option to create the .M file each time you save the notebook. I don't like to write .M package files directly because all the special characters have to be spelled out in such an ugly way - inevitably, since Mathematica uses so many extra characters. You can test your code while it is in the notebook and only use the .M file with working code in it. David Bailey dbaileyconsultancy.co.uk === Subject: Re: How to match/balance parenthesis? Double-click either paren, brace, or bracket. Bobby > I have been looking for a hot key or menu option that will help me > determine which set of parenthesis, curly braces, or brackets they > belong to in a mathematica v 5.0.1.0 notebook. (e.g. {{{ }}}). > Is there such a feature, and if so how do I get it to work? > -B -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: How to match/balance parenthesis? {{{ a + b }, (c + d)/(e + f)}} Click anywhere in the above expression and then use Shift+Ctrl+B (repeatedly) to obtain successfully larger matching brackets. It is also on Menu/Edit/CheckBalance. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ I have been looking for a hot key or menu option that will help me determine which set of parenthesis, curly braces, or brackets they belong to in a mathematica v 5.0.1.0 notebook. (e.g. {{{ }}}). Is there such a feature, and if so how do I get it to work? -B === Subject: HDF5 Data Format I have a file of 350 MB and it is in HDF5 format I know Mathematica supports this file... is there anyway to see and get whatever I want from this file? I am new to play with data with Mathematica and I would like to know if anyone knows how to manipulate such a big data file with the use of mathematica from my personal pc with its limited capabilities.If someone can help it would be really helpful === Subject: Re: repeating elements in a list > suppose I have list > lst={A, B, C} > and I want to create a new list, where all elements are repeated n times > so that (for n=3): > newlst={A, A, A, B, B, B, C, C, C} > I have the following code to do this: > n=3; > newlst=Flatten[Table[Table[lst[[i]], {n}], {i, Length[lst]}]]; > but I'm pretty sure, that there must be a more elegant way to solve the > problem. > thank you Flatten[Table[#, {3}] & /@ lst, 1]; -- Peter Pein Berlin === Subject: Re: repeating elements in a list > suppose I have list > lst={A, B, C} > and I want to create a new list, where all elements are repeated n times > so that (for n=3): > newlst={A, A, A, B, B, B, C, C, C} > I have the following code to do this: > n=3; > newlst=Flatten[Table[Table[lst[[i]], {n}], {i, Length[lst]}]]; > but I'm pretty sure, that there must be a more elegant way to solve the > problem. I would do it like so: Join @@ ( Table[#,{n}]& /@ lst ) Using Join instead of Flatten allows you to also make n copies of list objects, if that is the desired behavior: In[1]:= lst = {{A,B},C,D} Out[1]= {{A, B}, C, D} In[2]:= n=3 Out[2]= 3 In[3]:= Join @@ ( Table[#,{n}]& /@ lst ) Out[3]= {{A, B}, {A, B}, {A, B}, C, C, C, D, D, D} Scott -- Scott Hemphill hemphill@alumni.caltech.edu This isn't flying. This is falling, with style. -- Buzz Lightyear === Subject: Re: repeating elements in a list Flatten[Table[#, {n}] & /@ lst] Mitch Stonehocker -----Original Message----- === Subject: repeating elements in a list suppose I have list lst={A, B, C} and I want to create a new list, where all elements are repeated n times so that (for n=3): newlst={A, A, A, B, B, B, C, C, C} I have the following code to do this: n=3; newlst=Flatten[Table[Table[lst[[i]], {n}], {i, Length[lst]}]]; but I'm pretty sure, that there must be a more elegant way to solve the problem. thank you