delay wget progress bar display interval - wget

How to delay the wget progress bar updating/refreshing interval?
By default it updates every milliseconds and each update will be captured as a single line to a STDOUT file when run in a job script that causes the job script STDOUT file large. I don't want to disable the progress bar completely as I still want to know the progress at different time.

wget knows the --progress option, that allows you to tweak the output settings a bit. An excerpt from the manpage:
--progress=type
Select the type of the progress indicator you wish to use. Legal indicators are
"dot" and "bar".
[...]The "bar" indicator is used by default. It draws an ASCII progress bar graphics
(a.k.a "thermometer" display) indicating the status of retrieval. If the output is
not a TTY, the "dot" bar will be used by default.
Use --progress=dot to switch to the "dot" display. It traces the retrieval by
printing dots on the screen, each dot representing a fixed amount of downloaded data.
The progress type can also take one or more parameters. The parameters vary based on
the type selected. Parameters to type are passed by appending them to the type
sperated by a colon (:) like this: --progress=type:parameter1:parameter2.
When using the dotted retrieval, you may set the style by specifying the type as
dot:style. Different styles assign different meaning to one dot. With the "default"
style each dot represents 1K, there are ten dots in a cluster and 50 dots in a line.
The "binary" style has a more "computer"-like orientation---8K dots, 16-dots clusters
and 48 dots per line (which makes for 384K lines). The "mega" style is suitable for
downloading large files---each dot represents 64K retrieved, there are eight dots in
a cluster, and 48 dots on each line (so each line contains 3M). If "mega" is not
enough then you can use the "giga" style---each dot represents 1M retrieved, there
are eight dots in a cluster, and 32 dots on each line (so each line contains 32M).
With --progress=bar, there are currently two possible parameters, force and noscroll.
When the output is not a TTY, the progress bar always falls back to "dot", even if
--progress=bar was passed to Wget during invokation. This behaviour can be overridden
and the "bar" output forced by using the "force" parameter as --progress=bar:force.
By default, the bar style progress bar scroll the name of the file from left to right
for the file being downloaded if the filename exceeds the maximum length allotted for
its display. In certain cases, such as with --progress=bar:force, one may not want
the scrolling filename in the progress bar. By passing the "noscroll" parameter,
Wget can be forced to display as much of the filename as possible without scrolling
through it.
Note that you can set the default style using the "progress" command in .wgetrc.
That setting may be overridden from the command line. For example, to force the bar
output without scrolling, use --progress=bar:force:noscroll
I recommend to read the whole thing to understand how wgets progress meter works, but these are the important points in a nutshell:
if the output is not a tty, wget will use the dot display method
the dot display method displays a . per X number of bytes downloaded
X can be tweaked by passing --progress=dot:<style> to the wget call
style can be one of:
default: 1KB per dot
binary: 8KB per dot
mega: 64KB per dot
giga: 1MB per dot
To summarize, in order to reduce the output when downloading a large file, you would invoke wget as follows:
$> wget --progress=dot:mega <url>

Related

how to show the linearization result in Dymola?

I tried to use the linearization function in Dymola, but it seems when the result's dimension is large, Dymola won't show the result.
My question is:
How could I print the result or where to find it?
What you can do, is assign the result to a variable. This can be done using the Outputs group as shown in the screenshot below. If you e.g. enter "sys" in the field for ss, you will get a record sys, in which you can access the matrices/vectors by typing sys.A, sys.B etc., which I've tested for a system of size 200x200. Typing this into the command line will display the content. Of course this record not only for outputting it, but also for post-processing.
The only thing this actually does, is modify the call from Modelica_LinearSystems2.ModelAnalysis.Linearize("ModelName") to sys=Modelica_LinearSystems2.ModelAnalysis.Linearize("ModelName"), so it can be done in the Commands window as well.
Call the function from the command line and capture the output. Then you can do with it what ever you want.
Everything you find in the Linear Analysis toolbar is part of the library Modelica_LinearSystems2. The Linearize item in this menu calls the function
Modelica_LinearSystems2.ModelAnalysis.Linearize("<your-model>")
which is also printed to the command line. The function returns the operator record Modelica_LinearSystems2.StateSpace, which contains all the info you are interested in. The default behavior of Dymola is to call the String method of this operator record and print it to the command line. If you look at the source code of Modelica_LinearSystems2.StateSpace.'String' you can see this at the start of the algorithm section:
// If system is too large, do not print the matrices
if size(ss.A,1) > 50 or size(ss.B, 2) > 50 or size(ss.C, 1) > 50 then
...
On the command line you can capture the operator record in a variable like this:
stateSpace = Modelica_LinearSystems2.ModelAnalysis.Linearize("<your-model>");
And then access the values on the command line via
stateSpace.A
stateSpace.B
stateSpace.C
stateSpace.D
For a nice html report you can also pass the operator record to one of the analysis functions:
Modelica_LinearSystems2.StateSpace.Analysis.analysis2.printSystem(stateSpace)
This creates the file systemAnalysis.html in your working directory, containing a nice visual presentation of your system.

ImageMagick: How to batch append 4 parts of images into one (2 rows, 2 columns) (I have 500+ images that need to be combined like this)

everyone!
I am using ImageMagick-7.0.10-Q16 on Windows 10. I’ve tried Googling for answers, but I’m still left very confused about how to do this. Most of the answers have been for UNIX and not Windows, I have no idea what it means, or given me errors. I don’t have any experience with coding or Windows PowerShell, so forgive my slowness
I have scanned pages of books that have been split into four pieces of jpg files. The images are named after the page number and the orientation of the corresponding piece. BL=Bottom left. BR=Bottom right. TR=Top right. TL=Top left. (BM=Bottom pieces merged. TB=Top pieces merged). So “BL0001.jpg" is the bottomleft piece of page 1. I’m not mentioning their sizes because I don’t want them to be resized or whatever. I just want them to be combined via append like a puzzle like this:
Combined jpg pieces.
The borders and the text-boxes there are just to demonstrate, and are not to be included
So the files are for example like this:
BL0001.jpg
BR0001.jpg
TL0001.jpg
BR0001.jpg
BL0002.jpg
BR0002.jpg
TL0002.jpg
BR0002.jpg
And so on...
This was the last thing I’ve tried in Windows PowerShell:
magick convert B*0001.jpg +append 0001BM.jpg
magick convert T*0001.jpg +append 0001TM.jpg
magick convert 0001*.jpg +swap -append 0001merged.jpg
This combines 4 parts into one image just like I want it to. I found out adding * works like a wildcard and merges all the images like BR and TR together in one go. But I can’t do that for the page number (in this case ‘0001’ in ‘B*0001.jpg’), because that would merge all the files in the folder into the same image, something I don’t want. So what I want to figure out is to how to “batch” run this command for with a sequential numbering system for the different pages. In other words, use a command to batch combine pieces of an image into one image, but with all the scanned pages in jpg in the folder. I know the commands above create addition files with the merged top and bottom parts before the final merge, but I don’t know how to make this command otherwise. I'm willing to try other commands/things too
Using ImageMagick v7 in a simple Windows BAT script you could do something like this...
#echo off
setlocal EnableDelayedExpansion
for /l %%n in ( 1 1 9999 ) do (
set V1=000%%n
set V1=!V1:~-4!
magick *!V1!.jpg +append -crop 2x1# +swap -append +repage !V1!merged.jpg
)
exit /b
That uses a "for" loop to read all four "*0001.jpg" images at a time into an ImageMagick command. The "set V1=" lines are to make sure the variables have the correct number of leading zeros.
The IM command appends, crops, and appends the four images into the properly ordered output, and writes the image as "0001merged.jpg". Then it moves on to process "*0002.jpg" and so on.
I put a top limit on the number of image sets to process with that "9999" in the "for" command to work with the number of leading zeros. Make sure that number is the same or more than the number of image sets you have. It will just print an error for each loop after it goes over the number of image sets, but no harm done.
Note: Using ImageMagick v7 you should just use "magick" because when you use "magick convert" it emulates IMv6 behavior. You probably won't usually want that.

Defining what is a line in Tesseract

I'm working on document recognition for scanned bank statement. The statements that I have are organized by lines, such as the one attached. Because Tesseract does such a good job at detecting the areas of text, it breaks the lines in the middle (I'm assuming this is because of the large white space between the first block in the line (blurred for privacy reason), and the next one ('EUR', or 'COURS').
In the hocr file, the bbox of all the elements in the line are within 2px or so, so I could potentially rebuild a line myself. However, this seems more like a hack. Is there a way to tell Tesseract that lines should be as wide as the document itself? Or would there be another way to go about it? I've tried playing with the psm option, but with no luck.
-psm 6 -- Assume a single uniform block of text -- should work. If not, you may want to use the older version 2.0x, which does not perform page layout analysis.

How to read the first (and only) line of a file, split it into separate strings and append it to variables using csh?

I need some help with the following problem. I just can't figure it out (and yes I did the googlework etc).
Using csh I need to read one line from a file (there is only 1 line in the file), split it into separate strings (!not every value is separated with a space, however they do have a fixed position (always in the 3rd and 4th field)) and assign two of them to two separate variables in long format (so no E+04). The two values of interest are:
82390.43500000000
and
4.167000000000000
(so without the 'Earth' attached to it).
They need to be assigned to respectively time and time_step.
The inputfile temp.txt looks like:
000520000001 260026 8.239043500000000E+04 4.167000000000000E+00Earth Centred Rotating -9.999999999999998E+03-9999999.9999999-9999999.9999999-9999999.9999999
There are multiple files called temp.txt, however placed in different folders. The only part that stays constant in all files is Earth Centred Rotating.
What is the best way to do this (awk/grep/sed/?)?
Thanks!
awk '{sub(/E.*/,"",$3); print$3}' temp.txt
and
awk '{sub(/E.*/,"",$4); print$4}' temp.txt
gives 82390.43500000000 and 4.167000000000000 respectively which can then be assigned to your variables.

Is there a way to detect when a field mark with 'can grow' has truncated the field data?

I do not normally work with crystal, but I have spent nearly 2 days looking for a way to do this.
The problem is that I have a number of lines of text that need to show on a report, but need to cut off after 8 lines and show a 'more' prompt to inform the user that they need to go look at the rest of the details online. This was originally handled by storing the data as individual lines already wrap to size and counting the lines with a formula and conditionally showing a separate 'more' field. They have since added the ability to use html to the text, but this made the current way of doing things wrap incorrectly and show the html mark up.
I wrote a database function to combine the text into a single field and use the HTML text interpretation to display it correctly on 7 other reports that do not limit the text length, and the max line count works great for limiting the text size, I just can't figure out how to show the 'more' prompt when needed.
Any suggestions would be greatly appreciated.
GrumpyGeek,
If your database function now combines the text into a single field does this mean the original way, with the separated lines, is still stored? If so, why not add another calculated field called 'line-count' that tallies the old line-based data?
So you'd still have your new combined HTML field and this new field that you could use to show the 'more' button when 'line-count > x'?
Alternatively, another option might work, but would be a bit touchy. That is to make the formula that shows the more button trigger when the field length exceeds x. The catch is that html mark-up isn't displayed, and heavy use of it would skew the amount of text required before you should show the 'more' button. Put another way, a field with very heavy use of mark-up ( and tags) might force the 'more' button earlier than it should. Unless you could somehow make either your 'line-count' calculated field exclude the mark-up OR make the length calculation do the same.
This would be possible if MSSQL or Crystal Reports could run regex to strip the mark-up.
If NONE of the above works, the only other thing I can suggest is to look into UDFs. Crystal allows you to load an external library that you write. These will read functions you write and show them in the function list inside Crystal. If you do this, then you could easily write a routine that strips the HTML and calculates when the more button should be shown.
Good luck with it.
Ideally, there would be a property of the DB field that would return its displayed line count. Unfortunately, there is no such property.
You could try counting the # of line ending characters (e.g. carriage return, line feed). If they are > 7 then show the hyperlink. In a HTML situation, you have to count ending elements (e.g. ). You could make use of a RegEx UFL to make it easier to identify the elements.
Probably the easiest route is to the DB to calculate the # of lines and return that as another field. Use this field to hide/show the hyperlink.