I need to change a few values in a couple of FITs image headers to fit with some test data I have. Therefore I'm trying to hack a FITs image header at the minute to run with the application.
However at the minute - I can't even see the header, never mind hack it. I run Ubuntu.
Can anyone advise some software to view the FITs - perhaps even hack it?
Kind of old, but I think the answer could use some updates and additional information.
View .fits file
My personal favorite GUI for viewing '.fits' files is DS9. Once installed you can view a file by typing ds9 /path/to/file.fits. Alternatively you can just use the menu in the GUI to load the image. Once you load the image in the viewer, you can view the header information by using the very top menu bar and going to 'File -> Display Header'. Unfortunately, I dont believe you can modify the header in DS9.
Modify fits header
For modifying the fits header, I found the easiest is to use astropy (a python package). Since you're using Ubuntu you should be able to download it via apt-get, so hopefully pretty easily. To actually edit the fits header, you can do the following in a python script, or from the interpreter (here's some additional help):
# Import the astropy fits tools
from astropy.io import fits
# Open the file header for viewing and load the header
hdulist = fits.open('yourfile.fits')
header = hdulist[0].header
# Print the header keys from the file to the terminal
header.keys
# Modify the key called 'NAXIS1' to have a value of 100
header['NAXIS1'] = '100'
# Modify the key called 'NAXIS1' and give it a comment
header['NAXIS1'] = ('100','This value has been modified!')
# Add a new key to the header
header.set('NEWKEY','50.5')
# Save the new file
hdulist.writeto('MyNewFile.fits')
# Make sure to close the file
hdulist.close()
You could also throw this in a loop for multiple file manipulation.
If you are familiar with the python programming language, you could use the astropy module to view and manipulate fits files. Say you want to view the header of the file 'image.fits', then you do:
from astropy.io.fits import getheader
header = getheader('image.fits') # Load the data
print header # Print the header to screen
If you want to modify a particular key of the header, you do:
header['key'] = 'new_key'
edhead seems to do the job very well. Only piece of software I have found that allows you to edit the header at the command line.
Is this the Flexible Image Transport System format used by Astronomers?
This site has some background information and further links, but explains that
Users must develop or obtain separate software to read and display the data from the FITS file. There are a number of different packages for particular applications and hardware, but there is no single standard package for all applications.
Still, you can use it for your own purposes.
As only 1/2 of the question was answered (editing the FITS headers), to view the images, I commonly use DS9 (aka SAOImage).
Also, if you're going to be editing a lot of FITS headers, I tend to go with either CFITSIO or Astro::FITS::Header
... and it's possible to edit FITS headers with any text editor, so long as you follow a few simple rules -- cards (key/value/comment sets) are always 80 characters long, and the FITS header is always a multiple of 2880 bytes. Depending on the file, there might be multiple headers, as the first header could declare the file to contain multiple images or tables.
The Sloan Digital Sky Survey developer web site has some libraries that should meet your needs.
FitsLib - A library for reading and manipulating FITS files on the Microsoft's .Net platform.
FITS stands for flexible image transport system. FitsLib aims to provide an interface to the FITS file on the Dot Net Platform. It is built as an object oriented wrapper around the CFITSIO library's interface to the FITS files.
While FitsLib itself is designed for C# and the .NET Framework, you might be able to use it under Mono on your Ubuntu system. Or, perhaps you can use the CFITSIO library directly, which is written in C.
Related
Software: Octave v7.1.0
There seems to be no option of defining the page size while doing publish ("FILE", "pdf") . The manual for pdf is: 11.11.1 docs.octave/.../Publish.
It's kinda surprising as it's a one word addition to the output TeX file : a4paper. I can do this manually each time I publish but being able to specify it somehow within the publish function would be awesome.
Surprisingly, there are plenty options for specifying page size in figures and images. Search for papertype at: 15.3.3.2 docs.octave/.../Figure-Properties
I searched with "Matlab" and found this page, and it fetched the results for "Matlab Report Generator" mlreportgen which seems a different thing.
I'd be interested to listen about other ways of doing it automatically too (like adding that word in TeX file via shell scripting and text string manipulation maybe).
As directed by #cris-luengo in the pointer comment to the linked manual, one solution can be to edit (or create) the function files (to used by the publish function) with the desired changes to specify the paper size.
The function files location can be found by:
opening the function file in octave gui and then proceeding from there:
edit (fullfile (fileparts (which ("publish")), "private", "__publish_html_output__.m"))
or, executing the following in octave REPL/command line:
fullfile (fileparts (which ("publish")), "private")
There, among other files, 2 files will be:
__publish_html_output__.m
__publish_latex_output__.m
Edit the _latex_ containing file to add ,a4paper (or other predefined size in latex) alongwith 10pt in the line '\documentclass[10pt]{article}',, optionally with a comment in a proceeding newline as a reminder that you added it, something like: '% Modification: specify a4paper',
If pdf format were directly specified as a new function file, then I'd have preferred to modify its copy and calling that directly in publish(), but since the publish pdf eventually calls publish latex, so, the only option at hand in this method seems to edit the original publish latex function file itself.
I would like to import an external data source into another file.
The way the work flow is distributed right now makes no sense and having the layout open in another window is not really needed.
What I'd like to do is import the whole external file(databases, records, layouts, and scripts) into the first file. Is it possible to automate this process or do I have to import everything manually step-by-step?
There is no automatic way to import code from one FileMaker file to another.
External file references, custom functions, tables, fields, value lists, themes, layouts, scripts, layout objects, menus, ... have to be painstakingly moved by hand, bit by bit!
Order!
Most important is the order in which you do things!
Do it in the wrong order, and references break because the referenced thing has not yet been created in the target file.
The chicken / egg conundrum
Even then you still get "what comes first? chicken/egg" conundrums - due to cyclic references.
For example a layout-button might reference a script, and the script might reference the layout the button is in.
=> That means, if you create the layout first (layout, layout-settings, layout-parts, contents and all) the [Button] breaks (because the script is missing) and if you create the script first the Go to Layout breaks (because the layout is missing). :-/
For this reason you often have to create the object "shells" before you create the contents.
In the given example you would do this:
First create the empty layout (and layout parts with the correct heights)
Then import (or copy/paste) the script
Finally copy & paste the layout contents
Like this, the script can reference the layout ok and the button can reference the script ok.
Useful resources
Geist Interactive have a good post Checklist moving FileMaker code explaining which order to use.
My toolbox fmWorkMate (from www.fmworkmate.com
) and particularly the fmLogAnalyser tool is very useful for catching and tracking breakages when copying and pasting code
I'm using PhpStorm 10.0.4
When I start typing characters in project tool window it searchs for files containing typed text.
Is it possible to change this behavior so only files that begins with typed text would be matched?
Is it possible to change this behavior so only files that begins with typed text would be matched?
AFAIK no. There are no GUI settings for this at all.
Plus, this Speed Search is used in many places/tool windows and search logic is the same.
P.S. If you need to search for files .. why not try more appropriate (in general sense) Navigate | File... instead?
Speed Search only finds items in already expanded nodes (as it's a basic search on already displayed text) .. but Navigate | File... will look for files everywhere in the project.
It's not possible directly but you can create and use a scope for that.
Open Settings and go the Appearance & Behaviour -> Scopes. Create a new scope, give it a name (let's say "My Files") and put file:*/c* in the Pattern edit box.
In the big list of files under the Pattern edit box you can preview its effects. The files that are included in the scope are colored in green, the directories that contain included files are colored in blue.
This simple pattern selects only the files whose name start with c, in all directories. You can use slightly more complex filters using wild cards, include or exclude entire directories etc. With a little practice you can create filters that match usual needs pretty well.
When you are pleased with the scope definition, close the Settings box and go back to the Project view. Click on the arrow next to Project and you'll get a list of views of the project files. All the scopes you created should be there. Select "My Files" and only the files (and directories) included in that scope will be displayed in the Project view.
It is not a dynamic filter, you have to work a little to set it up, but it is useful when you work on large projects, with thousands of files, and you need to hide the files not important for your task.
I have been asked to update a system where header information gets injected into a tif via a 3rd party console application. I don't need to worry about that bit.
The part I have been asked to look at it the merge process that generates the header information.
The current file generated by the process is assumed as correct, before I make any changes, so I want to add this as an approved result, from that I can then check that the changes I make will alter the file as expected.
I thought this would be a good opportunity to look at using ApprovalTests
The problem I have is that for what ever reason the links to the videos are considered corruptible (Possibly show me kittens jumping into boxes or something, which will stop me working, which ironically means I slow down my work done because I cannot see any help videos).
What I have been looking at is the Approvals.Verify and Approvals.VerifyFile extensions.
But what appears to be happening is confusing me.
using VerifyFile creates a received file, but the contents of the file are just a line the name of the file I have asked it to verify.
using Verify(new FileInfo("FileNameHere")) does not appear to generate the received file that I need to flag as approved, but the test does return saying that it cannot find the approved tif file.
I am probably using VerifyFile completely wrong and might be looking at using Verify wrong as well.
useful info?
Might be useful to know, that as this is a legacy application, running as a windows service, I have wrapped the service in a harness that allows me to call the routines, so the files are physically being written elsewhere on the machine outside of my control (well there is a config, but the return of the service I call generates a file in a fixed location if it is successful). I have tried copying that into the Unit Test project, but that doesn't appear to help.
Verify(File) and VerifyFile(string) are both meant to verify an existing file. As such they merely setting the received file to the file you pass in. You will still need to move/approval/create the approved file.
Here is the pseudo code and process.
[UseReporter(typeof(DiffReporter), typeof(ClipboardReporter)]
public void TestTiff()
{
string tif = YourProcessToCreateTifFile();
Approvals.VerifyFile(tif);
}
[Note: if you don't have an image diff installed, like TortoiseDiff, you might want to use the FileLauncherReporter]
Run this, once you get the result, move the file over by pasting your clipboard into a cmd window.
It will move the temporary tif to your test directory with the name ClassName.TestTiff.approved.tif
After that the test should pass until something changes.
Happy Testing!
firstly I'll give some background regarding the situation.
I have a website containing approximately 56k pages each page contain a mapped sketch of a machine part. this machine part is made out of smaller parts which are outlined in the image and hold a certain number. when you hover over the numbers a box with the part item code shows up.
I order parts according to this item codes but recently a lot of the items codes have changed, therefore I am looking for a solution.
now I own a database with data on all the 56k parts and I want to link the relevant webpage to each record according to the name of the part(a column in my database), the problem is that the webpages names has no logic name that could connect with the part name in any way but the image that is displayed in the page has the exact name of the part.
I want to rename all the html files I has according to the Images displayed within them. how can I achieve that without renaming all the 56k pages manually?
additionally how can I add the links to all the 56k pages automatically to my database after all the above is done?
Thank you for your patience I know it was long.
If you have a *nix shell, then a simple egrep will get you far
egrep "<img src=\".*\"" -r . > list
The regexp would have to be adapted to match the part you are looking for of course.
You could easily to some search/replace in the resulting list to create a batch script that will do all the renaming for you.
Pick your favorite scripting language and parse each html file to find the image name to use in renaming the file. Personally I would use Perl as it makes parsing the files and updating a database at the same time with the URL easy.