How can I extract, edit and replot a data matrix in Abaqus? - matrix

Good afternoon,
We´ve been working on an animal model (skull) applying a series of forces and evaluating the resultant stresses in Abaqus. We got some of those beautiful and colourful (blue-to-red) contour-plots. Now, we´d like to obtain a similar image but coloured by a new matrix, which will be the result of some methematical transformations.
So, how can I extract the data matrix used to set those colour patterns (I guess with X-, Y-, Z-, and von Mises-values or so), apply my transformation, and replot the data to get a new (comparable) figure with the new values?
Thanks a lot and have a great day!

I've never done it myself but I know that this is possible. You can start with the documentation (e.g. here and here).
After experimenting using GUI you can check out the corresponding python code which should be automatically recorded in the abaqus.rpy file at your working directory (or at C:\temp). Working it trhough you could get something like:
myodb = session.openOdb('my_fem.odb') # or alternatively `session.odbs['my_fem.odb']` if it is already loaded into the session
# Define a temporary step for accessing your transformed output
tempStep = myodb.Step(name='TempStep', description='', domain=TIME, timePeriod=1.0)
# Define a temporary frame to storeyour transformed output
tempFrame = tempStep.Frame(frameId=0, frameValue=0.0, description='TempFrame')
# Define a new field output
s1f2_S = myodb.steps['Step-1'].frames[2].fieldOutputs['S'] # Stress tensor at the second frame of the 'Step-1' step
s1f1_S = myodb.steps['Step-1'].frames[1].fieldOutputs['S'] # Stress tensor at the first frame of the 'Step-1' step
tmpField = s1f2_S - s1f1_S
userField = tempFrame.FieldOutput(
name='Field-1', description='s1f2_S - s1f1_S', field=tmpField
)
Now, to display your new Field Output using python you can do the following:
session.viewports['Viewport: 1'].odbDisplay.setFrame(
step='TempStep', frame=0
)
For more information on used methods and objects, you can consult with the documentation "Abaqus Scripting Reference Guide":
Step(): Odb commands -> OdbStep object -> Step();
Frame(): Odb commands -> OdbFrame object -> Frame();
FieldOutput object: Odb commands -> FieldOutput object;

Related

Set the name for each ParallelFor iteration in KFP v2 on Vertex AI

I am currently using kfp.dsl.ParallelFor to train 300 models. It looks something like this:
...
models_to_train_op = get_models()
with dsl.ParallelFor(models_to_train_op.outputs["data"], parallelism=100) as item:
prepare_data_op = prepare_data(item)
train_model_op = train_model(prepare_data_op["train_data"]
...
Currently, the iterations in Vertex AI are labeled in a dropdown as something like for-loop-worker-0, for-loop-worker-1, and so on. For tasks (like prepare_data_op, there's a function called set_display_name. Is there a similar method that allows you to set the iteration name? It would be helpful to relate them to the training data so that it's easier to look through the dropdown UI that Vertex AI provides.
I reached out to a contact I have at Google. They recommended that you can pass the list that is passed to ParallelFor to set_display_name for each 'iteration' of the loop. When the pipeline is compiled, it'll know to set the corresponding iteration.
# Create component that returns a range list
model_list_op = model_list(n_models)
# Parallelize jobs
ParallelFor(model_list_op.outputs["model_list"], parallelism=100) as x:
x.set_display_name(str(model_list_op.outputs["model_list"]))

PyRadiomics: How to extract features from Gray Level Run Length Matrix using PyRadiomix library for a .jpg image

I am unable to extract GLRLM features using the PyRadiomix library for a .jpg file. It has also a mask input, which is not clear to me.
import SimpleITK as sitk
from radiomics import glrlm
from radiomics import featureextractor
image = sitk.ReadImage('D:\Desert.jpg', imageIO="JPEGImageIO")
extractor = featureextractor.RadiomicsFeatureExtractor()
extractor = featureextractor.RadiomicsFeatureExtractor(binWidth=20, sigma=[1,
2, 3], verbose=True)
# Disable all feature classes, save firstorder
extractor.disableAllFeatures()
extractor.enableFeatureClassByName('glrlm')
extractor.enableFeaturesByName(glrlm=['SRE', 'LRE','GLN','GLNN','RLN','RLNN','RP','GLV','RV','RE','LGLRE','HGLRE','SRLGLE','SRHGLE','LRLGLRE','LRHGLRE'])
******result = extractor.execute(imagePath, labelPath)*******
I got this code from the PyRadiomics website. But at the last line, I can't understand the two parameters
From the documentation:
execute(imageFilepath, maskFilepath, label=None, label_channel=None, voxelBased=False)
Compute radiomics signature for provide image and mask combination. It comprises of
the following steps:
Parameters:
imageFilepath – SimpleITK Image, or string pointing to image file location
maskFilepath – SimpleITK Image, or string pointing to labelmap file location
label – Integer, value of the label for which to extract features. If not specified, last specified label is used. Default label is 1.
label_channel – Integer, index of the channel to use when maskFilepath yields a SimpleITK.Image with a vector pixel type. Default index is 0.
voxelBased – Boolean, default False. If set to true, a voxel-based extraction is performed, segment-based otherwise.
Therefore in the call
result = extractor.execute(imagePath, labelPath)
labelPath plays the role of maskFilepath in the signature.

Any ar js multimarkers learning tutorial?

I have been searching for ar.js multimarkers tutorial or anything that explains about it. But all I can find is 2 examples, but no tutorials or explanations.
So far, I understand that it requires to learn the pattern or order of the markers, then it stores it in localStorage. This data is used later to display the image.
What I don't understand, is how this "learner" is implemented. Also, the learning process is only used once by the "creator", right? The output file should be stored and then served later when needed, not created from scratch at each person's phone or computer.
Any help is appreciated.
Since the question is mostly about the learner page, I'll try to break it down as much as i can:
1) You need to have an array of {type, URL} objects.
A sample of creating the default array is shown below (source code):
var markersControlsParameters = [
{
type : 'pattern',
patternUrl : 'examples/marker-training/examples/pattern-files/pattern-hiro.patt',
},
{
type : 'pattern',
patternUrl : 'examples/marker-training/examples/pattern-files/pattern-kanji.patt',
}]
2) You need to feed this to the 'learner' object.
By default the above object is being encoded into the url (source) and then decoded by the learner site. What is important, happens on the site:
for each object in the array, an ArMarkerControls object is created and stored:
// array.forEach(function(markerParams){
var markerRoot = new THREE.Group()
scene.add(markerRoot)
// create markerControls for our markerRoot
var markerControls = new THREEx.ArMarkerControls(arToolkitContext, markerRoot, markerParams)
subMarkersControls.push(markerControls)
The subMarkersControls is used to create the object used to do the learning. At long last:
var multiMarkerLearning = new THREEx.ArMultiMakersLearning(arToolkitContext, subMarkersControls)
The example learner site has multiple utility functions, but as far as i know, the most important here are the ArMultiMakersLearning members which can be used in the following order (or any other):
// this method resets previously collected statistics
multiMarkerLearning.resetStats()
// this member flag enables data collection
multiMarkerLearning.enabled = true
// this member flag stops data collection
multiMarkerLearning.enabled = false
// To obtain the 'learned' data, simply call .toJSON()
var jsonString = multiMarkerLearning.toJSON()
Thats all. If you store the jsonString as
localStorage.setItem('ARjsMultiMarkerFile', jsonString);
then it will be used as the default multimarker file later on. If you want a custom name or more areas - then you'll have to modify the name in the source code.
3) 2.1.4 debugUI
It seems that the debug UI is broken - the UI buttons do exist but are nowhere to be seen. A hot fix would be using the 'markersAreaEnabled' span style for the div
containing the buttons (see this source bit).
It's all in this glitch, you can find it under the phrase 'CHANGES HERE' in the arjs code.

Pyspark Streaming transform error

Hi I am new to Pyspark Streaming.
numbers0 = sc.parallelize([1,2,3,4,5])
numbers1 = sc.parallelize([2,3,4,5,6])
numbers2 = sc.parallelize([3,4,5,6,7])
stream0 = ssc.queueStream([numbers0, numbers1, numbers2])
stream0.pprint()
ssc.start()
ssc.awaitTermination(20)
ssc.stop()
This works fine but as soon as I do the following I get an error:
stream1 = stream0.transform(lambda x: x.mean())
stream1.pprint()
ssc.start()
ssc.awaitTermination(20)
ssc.stop()
What I want is stream that only consists of the mean of my previous stream.
Does anyone know what I must do?
The error you are getting when calling transform is because it requires an RDD-to-RDD function as stated in Spark's documentation for the transform operation. When mean is called on an RDD, it does not return a new RDD and therefore the error.
Now, from what I understand you want to calculate the mean of each RDD that consists the DStream. The DStream is created with the queueStream and since the named parameter oneAtATime is left to default, your program will consume one RDD at every batch interval.
To calculate the mean for each RDD, you would normally do this inside a forEachRDD output operation like this
# Create stream0 as you do in your example
def calculate_mean(rdd):
mean_value = rdd.mean()
# do other stuff with mean_value like saving it to a database or just print it
stream0.forEachRDD(calculate_mean)
# Start and stop the Streaming Context

Is it possible to display an Image in an autocompletion-popup list (Gtk3)

I am using an Entry with an EntryCompletion opbject that has a ListStore model.
For each record in the model, there is an image I would like to display in the autocomplete-popup list.
How can this be done?
Is it possible to add a Gtk.CellRendererPixbuf column to the model?
Interesting enough I could not find any examples of this yet it turns out to be possible and not insanely complicated. Lets start with a small image of the goal which uses icons for convinces reasons.
So how do we get there, first we create the ListStore containing a column with strings to match on and a icon-name to convert into a pixbuf (this could also be a pixbuf directly).
# Define the entries for the auto complete
entries = [
('revert', 'document-revert'),
('delete', 'edit-delete'),
('dev help', 'devhelp'),
]
# Setup the list store (Note that the data types should match those of the entries)
list_store = Gtk.ListStore(str, str)
# Fill the list store
for entry_pair in entries:
list_store.append(entry_pair)
Next step is setting up the EntryCompletion and linking it with the Liststore
# Create the Entry Completion and link it to the list store
completion = Gtk.EntryCompletion()
completion.set_model(list_store)
Now the magic, we need to create 2 renderers, one for the text, one for the pixbufs. We then pack these in the completion to add columns to it.
# Create renderer's for the pixbufs and text
image_renderer = Gtk.CellRendererPixbuf.new()
cell_renderer = Gtk.CellRendererText.new()
# Pack the columns in to the completion, in this case first the image then the string
completion.pack_start(image_renderer, True)
completion.pack_start(cell_renderer, True)
In order to make sure the renderers use the the correct column we here specify which column from the ListStore the renderers should read. For the image_renderer we set the icon_name attribute as we give it icon names. If we would feed it Pixbuf's we would need the pixbuf instead.
# Set up the renderer's such that the read the correct column
completion.add_attribute(image_renderer, "icon_name", 1)
completion.add_attribute(cell_renderer, "text", 0)
As there are no multiple column we need to tell the completion which column contains the string. In our case column 0.
# Tell the completion which column contains the strings to base the completion on
completion.props.text_column = 0
# Create the entry and link it to the completion
entry = Gtk.Entry()
entry.set_completion(completion)
And that's it!

Resources