text:
"""
Ships of the game.

Copyright: (c) 2017 by Yeison Valero.
License: MIT, see LICENSE for more information.
"""

import random
import time

import pygame

from src.bullet import Bullet
from src.utils import get_sprite

class Ship(object):
    """Base ship to make others more specialized."""

    def __init__(self, screen, image, bullet, speed, x, y, id_ship=None):
        """
        Load image of the ship and set attributes.
        Store screen as well.
        """
        # load image
        self.image = image
        # store screen
        self.screen = screen
        # save speed
        self.speed = speed
        # store bullet
        self.bullet = bullet

        # sprites of explosions
        self.explosions_sprites = self.get_sprites_exploding()

        # will be used like index to render all explosion's sprites
        self.count = 0

        # get rect of image and screen
        self.rect = self.image.get_rect()
        self.screen_rect = self.screen.get_rect()

        # set initial position
        self.rect.y = y
        self.rect.x = x

        # becase no ship will be set destroyed at
        # the start of the game
        self.destroyed = False
        # flag to know when update time_after_shot
        self.update_time_after_shot = True

        # ships' id
        self.id = id_ship

        # flag to know when pass the id to dead_ships list of Fleet_Enemy
        self.pass_id = False

        # ships won't can move when they are destroyed
        self.dont_move = False

        self.time_after_shot = time.time()
        self.time_before_shot = time.time()

    def get_sprites_exploding(self):
        """Return the sprites of explosions."""
        # path of the explosions images
        images_explosion_path = ["images/foo-0.png", "images/foo-1.png"]
        # that sprites are in two different images
        image1 = pygame.image.load(images_explosion_path[0])
        image2 = pygame.image.load(images_explosion_path[1])

        # locations of all spirtes in images
        location = [
            (0, 0, 25, 30), (25, 0, 45, 40),
            (70, 0, 40, 65), (110, 0, 32, 80),
            (140, 0, 40, 80), (178, 0, 54, 90),
            [0, 0, 35, 80]
        ]

        # will contain all sprites
        sprites = []

        # get exploding sprites
        sprite1 = get_sprite(image1, location[0])
        sprite2 = get_sprite(image1, location[1])
        sprite3 = get_sprite(image1, location[2])
        sprite4 = get_sprite(image1, location[3])
        sprite5 = get_sprite(image1, location[4])
        sprite6 = get_sprite(image1, location[5])

        # add sprites of 1st image
        sprites.append(sprite1)
        sprites.append(sprite2)
        sprites.append(sprite3)
        sprites.append(sprite4)
        sprites.append(sprite5)
        sprites.append(sprite6)

        # add sprites of the second one
        for x in range(6):
            sprite = get_sprite(image2, location[6])
            # increase x axis positions to can get the next sprite
            location[6][0] += 36

            sprites.append(sprite)

        return sprites

    def go_up(self):
        """Go upward if ship can move."""
        if not self.dont_move:
            self.rect.y -= self.speed

    def go_down(self):
        """Go downward if ship can move."""
        if not self.dont_move:
            self.rect.y += self.speed

    def go_left(self):
        """Go leftward if ship can move."""
        if not self.dont_move:
            self.rect.x -= self.speed

    def go_right(self):
        """Go rightward if ship can move."""
        if not self.dont_move:
            self.rect.x += self.speed

    def has_been_shot(self, ship):
        """Wheter it has been shot, change destroyed to True."""
        if ship.bullet.rect.colliderect(self.rect) and ship.bullet.fired and not self.destroyed:
            self.destroyed = True

            ship.bullet.reset_fired()
            ship.set_bullet_position(go_up=True)

    def collide_with(self, ship):
        """If it collide with ship switch destroyed to True."""
        # adapt player's rec to avoid collidings that don't look like one
        rect = self.rect.copy()
        rect_ship = ship.rect.copy()
        # first, its own rect
        rect.width = 35
        rect.height = 39

        # second, ship's one
        rect_ship.width = 35
        rect_ship.height = 39

        if rect_ship.colliderect(rect) and not self.destroyed:
            # change its own value to draw exploding sprites and stop moving
            self.destroyed = True

            # same thing here, but with the ship player
            ship.destroyed = True
            ship.dont_move = True

    def pass_id_to_dead_ships(self, dead_ships):
        """
        Pass the id of the ship to dead_ships list
        whether ship is destroyed.
        """
        if self.destroyed and self.pass_id:
            if not self.id in dead_ships:
                dead_ships.append(self.id)

    def has_been_shot_by_fleet(self, fleet):
        """Check if it has been shot."""
        for ship in fleet.ships.values():
            if ship.bullet.rect.colliderect(self.rect) and ship.bullet.fired:
                self.destroyed = True

                # reset bullet position, and now ship can shoot again
                ship.bullet.reset_fired()
                ship.set_bullet_position()

                break

    def process(self, ship_player=None, go_up=False,  fleet_1=[], fleet_2=[]):
        """Do actions of ship."""
        if not ship_player:
            self.has_been_shot_by_fleet(fleet_1)
            self.has_been_shot_by_fleet(fleet_2)
        else:
            self.has_been_shot(ship_player)

        if self.destroyed:
            self.dont_move = True

            # to avoid update time_after_shot over and over again
            if self.update_time_after_shot:
                # update time plus a mili seconds
                self.time_after_shot = time.time() + 0.1
                self.update_time_after_shot = False

        self.process_bullet(go_up)

    def set_bullet_position(self, go_up=False):
        """Set bullet position."""
        x, y = self.get_init_desired_bullet_pos(go_up)
        self.bullet.set_position(x, y)

    def is_out_of_screen(self):
        """Return True if it has gone out of screen else False."""
        if self.rect.y > self.screen_rect.bottom:
            return True
        else:
            return False

    def process_bullet(self, go_up=False):
        """
        Decrease or increase the y position of bullet if it has benn fired.
        Also reset its position whether it reach out the
        top or bottom of the screen.
        """
        if self.bullet.fired:
            if go_up:
                self.bullet.decrease_y()
            else:
                self.bullet.increase_y()

            self.reset_bullet_position(go_up)
        else:
            self.set_bullet_position(go_up)

    def get_init_desired_bullet_pos(self, go_up=False):
        """Return the initial desired position of bullet."""
        if go_up:
            x = self.rect.centerx - 2
            y = self.rect.top
        else:
            x = self.rect.centerx
            y = self.rect.bottom

        return (x, y)

    def reset_bullet_position(self, go_up=False):
        """
        Reset position of bullet if it's reached out the top of screen.
        """
        if self.bullet.rect.y < self.screen_rect.top or self.bullet.rect.y > self.screen_rect.bottom:
            self.set_bullet_position(go_up)
            self.bullet.reset_fired()

    def render_explosions(self):
        """Render the ship when it is exploding."""
        # keep count in the indexes
        if self.count >= 11:
            self.count = 0

        # update time_before_shot until reach out the desired time
        if self.time_before_shot < self.time_after_shot:
            self.time_before_shot = time.time()

        # to avoid render sprites too fast, whait a few mili seconds
        if self.time_before_shot > self.time_after_shot:
            self.count += 1
            # update again, that way it does not blit many sprites at one moment
            self.time_after_shot = time.time() + 0.1
            self.update_time_after_shot = True

            # to avoid pop ship out too early
            if self.count == 11:
                self.pass_id = True

        # adjust the x position to the center of the ship
        rect = self.rect.copy()
        rect.x = self.rect.x + 12

        self.screen.blit(self.explosions_sprites[self.count], rect)

    def render(self):
        """
        Render image on screen. Also render bullet if it has been fired.
        """
        if self.destroyed:
            self.render_explosions()
        else:
            self.screen.blit(self.image, self.rect)

        if self.bullet.fired:
            self.bullet.render()

class Ship_Player(Ship):
    """Ship that the user will control."""

    def __init__(self, screen, bullet_path, bullet_location):
        """Set attributes up and set initial position."""
        image_path = "images/ship.png"
        # load image
        self.image = pygame.image.load(image_path).convert_alpha()

        # instance bullet
        self.bullet = Bullet(screen, bullet_path, bullet_location)

        # make a difference speed of bullet for ship player
        self.bullet.speed = 10

        # get screen's rect
        screen_rect = screen.get_rect()

        speed = 8

        # set position at the middle bottom of screen
        x = screen_rect.centerx - 40
        y = screen_rect.bottom - 67

        # call superclass to initialize ship
        super(self.__class__, self).__init__(screen, self.image, self.bullet, speed, x, y)

        # set initial position of bullet
        self.set_bullet_position(go_up=True)

        # flag to know when stop game
        self.stop_game = False

        # stay at initial postion at the beginning
        self.moving_up = False
        self.moving_down = False
        self.moving_left = False
        self.moving_right = False

    def check_keyup(self, event):
        """Check key up arrows events."""
        if event.key == pygame.K_UP:
            self.moving_up = False
        elif event.key == pygame.K_DOWN:
            self.moving_down = False
        elif event.key == pygame.K_LEFT:
            self.moving_left = False
        elif event.key == pygame.K_RIGHT:
            self.moving_right = False

    def check_keydown(self, event):
        """Check key down arrows events."""
        if event.key == pygame.K_UP:
            self.moving_up = True
        elif event.key == pygame.K_DOWN:
            self.moving_down = True
        elif event.key == pygame.K_LEFT:
            self.moving_left = True
        elif event.key == pygame.K_RIGHT:
            self.moving_right = True
        elif event.key == pygame.K_SPACE:
            if not self.destroyed:
                self.bullet.shoot()

    def keep_moving(self):
        """Keep moving."""
        if self.moving_up and not self.rect.y < self.screen_rect.top:
            self.go_up()
        elif self.moving_down and not self.rect.y > self.screen_rect.bottom - 63:
            self.go_down()
        elif self.moving_left and not self.rect.x < self.screen_rect.left:
            self.go_left()
        elif self.moving_right and not self.rect.x > self.screen_rect.right - 59:
            self.go_right()

    def process(self, fleet1, fleet2, close_game_function, go_up=True, ship_player=True):
        """Process ship and bullet."""
        self.keep_moving()

        super(self.__class__, self).process(go_up=go_up, fleet_1=fleet1, fleet_2=fleet2)

class Ship_AI_Enemy(Ship):
    """Enemy ship with some AI."""

    def __init__(self, screen, bullet, x, y, id_ship=None):
        """Set position and turn image."""
        image_path = "images/ship.png"
        self.image = pygame.image.load(image_path).convert_alpha()

        # rotate image
        self.image = pygame.transform.rotate(self.image, 180)

        # get screen's rect
        screen_rect = screen.get_rect()

        speed = 2

        # store bullet
        self.bullet = bullet

        # rotate bullet
        self.bullet.image = pygame.transform.rotate(self.bullet.image, 180)

        # class superclass to initialize ship
        super(self.__class__, self).__init__(screen, self.image, self.bullet, speed, x, y, id_ship=id_ship)

        # set initial position of bullet
        self.set_bullet_position()

        # set default state machine. There are just two possible states: exploring and destroying
        self.state = "exploring"
        # flag to know whether or not it has reach out the destination
        self.has_come_dest = False

        # minimum distance to swtich to destroying state
        self.min_x_distance = 100
        self.min_y_distance = 450

        # at the beginning the destination is the initial
        # position but this will change
        self.x_dest = self.rect.x
        self.y_dest = self.rect.y

    def get_distance_to(self, ship):
        """Return the distance that separate it with ship."""
        distance_x = self.rect.x - ship.rect.x
        distance_y = self.rect.y - ship.rect.y

        return (distance_x, distance_y)

    def can_see(self, ship):
        """Wheter it can see ship, switch to destroying."""
        distance = self.get_distance_to(ship)
        min_x_distance = range(-self.min_x_distance, self.min_x_distance+10)

        if distance[0] in min_x_distance and distance[1] < self.min_y_distance:
            self.state = "destroying"
        else:
            self.state = "exploring"

    def set_destination(self):
        """Set destination randomly."""
        # get the positions available by speed
        dest_x = random.randint(self.screen_rect.left, self.screen_rect.right-53)
        dest_y = random.randint(self.screen_rect.top, self.screen_rect.bottom-90)

        # set new position of one of the options
        self.x_dest, self.y_dest = dest_x, dest_y

    def process(self, ship, dead_ships):
        """Process all actions."""
        # set which one of the two state is appropiate
        self.can_see(ship)

        if self.state == "exploring":
            self.explore()
        else:
            self.destroy(ship)

        super(self.__class__, self).process(ship_player=ship)
        self.pass_id_to_dead_ships(dead_ships)
        self.collide_with(ship)

    def can_shoot_to(self, ship):
        """Shoot if it is in front of the ship."""
        # make a range of approximation of the x of ship
        range_x = range(ship.rect.x-2, ship.rect.x+2)

        if self.rect.x in range_x and self.rect.y < self.min_y_distance and \
        not self.rect.y >= ship.rect.y:
            return True
        else:
            return False

    def destroy(self, ship):
        """Try to destroy ship."""
        # if ship is in front, shoot it
        if self.can_shoot_to(ship) and not self.destroyed:
            self.bullet.shoot()
        else:
            # if not, try to get closer to ship
            self.move_x(ship.rect.x)
            self.move_y(ship.rect.y)

    def explore(self):
        """Move around screen until find the ship."""
        # wheter it already has come to destination
        if self.has_come_to_dest():
            # set new destination
            self.set_destination()

        # if not, just keep moving until get to destination
        self.move_x(self.x_dest)
        self.move_y(self.y_dest)

    def has_come_to_dest(self):
        """"Check it it has come to destination. Return bool."""
        x_dest = range(self.x_dest-3, self.x_dest+5)
        y_dest = range(self.y_dest-3, self.y_dest+5)
        if self.rect.x in x_dest and self.rect.y in y_dest:
            return True
        else:
            return False

    def move_x(self, target):
        """Move right or left to get to x dest."""
        if self.rect.x < target:
            self.go_right()
        elif self.rect.x > target:
            self.go_left()

    def move_y(self, target):
        """Move up or down to get to y dest."""
        if self.rect.y < target:
            self.go_down()
        elif self.rect.y > target:
            self.go_up()

class Ship_Enemy(Ship):
    """Ship enemy."""

    def __init__(self, screen, bullet, x, y, id_ship=None):
        # load image
        image_path = "images/enemy.png"
        self.image = pygame.image.load(image_path).convert_alpha()

        self.speed = random.randint(1, 5)

        # initialize superclass
        super(self.__class__, self).__init__(screen, self.image, bullet, self.speed, x, y, id_ship=id_ship)

        # set initial bullet position
        self.set_bullet_position()

        # set destination
        self.set_destination()

        # times to decide when shoot
        self.time_to_shoot = time.time()
        self.time_to_wait = time.time() + 1

    def set_destination(self):
        """Randomly set destination."""
        self.dest_x = random.randint(self.screen_rect.left, self.screen_rect.right)
        self.dest_y = self.screen_rect.bottom + 50

    def shoot(self):
        """Every seconds if the random number are right, shoot."""
        if self.time_to_shoot < self.time_to_wait:
            self.time_to_shoot = time.time()
        else:
            if random.randint(0, 100) == random.randint(0, 100) and not self.destroyed:
                self.bullet.shoot()
                self.time_to_wait = time.time() + 1

    def process(self, ship, dead_ships):
        """Move to destination, and shoot randomly."""
        # shoot if a second has passed and the random numbers are right
        self.shoot()

        # move closer to destination
        self.move_x()
        self.move_y()

        # pass id to dead_ships if it is destroyed or out of screen
        self.pass_id_to_dead_ships(dead_ships)

        # others process, and see if it collide with ship
        super(self.__class__, self).process(ship_player=ship)
        super(self.__class__, self).collide_with(ship)

    def move_x(self):
        """Move closer to x destination."""
        if self.rect.x < self.dest_x and not self.rect.x in range(self.dest_x-4, self.dest_x+4):
            self.go_right()
        elif self.rect.x > self.dest_x and not self.rect.x in range(self.dest_x-4, self.dest_x+4):
            self.go_left()

    def move_y(self):
        """Move closer to y destination"""
        if not self.rect.y == self.dest_y:
            self.go_down()

class Fleet_Enemy:
    """"Fleet of Ships."""

    def __init__(self, screen, bullet_path, bullet_location, ai_ships=False, level=0):
        """Initialize fleet and set position."""
        # get screen's rect
        self.screen_rect = screen.get_rect()

        # store some parameters
        self.bullet_path = bullet_path
        self.bullet_location = bullet_location

        # id to identify each ship in the dictionary
        self.id = 0
        # number of ships that will form the flee0t
        if ai_ships:
            self.ships_number = 3
        else:
            self.ships_number = 7

        # will contain all ships and other one all id of
        # those that for one or another reason have to be deleted
        self.ships, self.dead_ships = {}, []

        # create ships
        self.make_ship(screen, bullet_path, bullet_location, ai_ships)

    def make_ship(self, screen, bullet_path, bullet_location, ai_ships=False, level=0):
        """Make n amount of ships and add it to the dict."""
        # depending on the level, make ships
        if not level == 0:
            if ai_ships:
                self.ships_number += 1
            else:
                self.ships_number += 2

        for x in range(self.ships_number):
            # instance a bullet for each ship
            bullet = Bullet(screen, bullet_path, bullet_location)

            # get the ship's position randomly
            x, y = self.get_random_pos()

            # create ship with a random position
            if ai_ships:
                ship = Ship_AI_Enemy(screen, bullet, x, y, id_ship=self.id)
            else:
                ship = Ship_Enemy(screen, bullet, x, y, id_ship=self.id)
            ship.set_bullet_position()

            # add it to the dict
            self.ships[self.id] = ship
            # increase id to avoid use it again
            self.id += 1

    def get_random_pos(self):
        """Return the desired random position of each ship."""
        x = random.randint(self.screen_rect.left, self.screen_rect.right)
        y = random.randint(self.screen_rect.top-100, self.screen_rect.bottom-500)

        return (x, y)

    def render(self):
        """Render all the fleet."""
        for ship in self.ships.values():
            ship.render()

    def reset_position(self, ship):
        """Reset the position of ship randomly."""
        x, y = self.get_random_pos()
        ship.rect.x = x
        ship.rect.y = y

    def remove_ship(self):
        """Delete ship from the dictionary."""
        for id_ship in self.dead_ships:
            del self.ships[id_ship]
            self.dead_ships.remove(id_ship)

    def process(self, ship, level, ai_ships=False):
        """Process all actions of every ship."""
        for ship_e in self.ships.values():
            ship_e.process(ship, self.dead_ships)
            # reset the position of ship if it's out of screen
            if ship_e.is_out_of_screen():
                self.reset_position(ship_e)
                ship_e.set_destination()

        # delete all those that are destroyed
        self.remove_ship()

redpajama_set_name: RedPajamaGithub


Oasis Biomate Pre-Filter Foams will suit a range of pond pumps, extending the time between pump maintenance, and avoiding large debris clogging your filter, thus ensuring the filter is working efficiently.
Now Suppied in black with a offset hole.
For a quote to ship outside mainland UK please contact us.


[1001.2232] Three candidate clusters of galaxies at redshift ~1.8: the "missing link" between protoclusters and local clusters?
Title:Three candidate clusters of galaxies at redshift ~1.8: the "missing link" between protoclusters and local clusters?
Abstract: We present three candidate clusters of galaxies at redshifts most likely between 1.7 and 2.0, which corresponds to a fundamentally unexplored epoch of clusters evolution. The candidates were found by studying the environment around our newly selected sample of "beacons" low-luminosity (FRI) radio galaxies in the COSMOS field. In this way we intend to use the fact that FRI at low z are almost invariably located in clusters of galaxies. We use the most accurate photometric redshifts available to date, derived by the COSMOS collaboration using photometry with a set of 30 filters, to look for three-dimensional space over-densities around our objects. Three out of the five FRIs in our sample which possess reliable photometric redshifts between z_phot = 1.7 and 2.0 display overdensities that together are statistically significant at the 4-sigma level, compared to field counts, arguing for the presence of rich clusters of galaxies in their Mpc environment. These first results show that the new method for finding high-z clusters we recently proposed, which makes use of low power FRI radio galaxies instead of the more powerful FRII sources often used in the literature to date, is returning very promising candidates.


text:
Tag: Florence
January 18, 2023 by Jessica In Florence, Italy
Florence City Guide
Street Art in Florence II
January 10, 2023 January 16, 2023 by Jessica In Florence, Italy
The saddest and sweetest sunset
January 6, 2023 by Jessica In Florence, Italy
Città Serena
December 30, 2022 January 16, 2023 by Jessica In Florence, Italy
Tuscany through the ages
December 6, 2022 January 16, 2023 by Jessica In Florence, Italy

redpajama_set_name: RedPajamaCommonCrawl


Those in the know about the astounding health benefits of coconut oil are usually well aware of the major antimicrobial effects this traditional fat has on the skin and also in the gut.
It is no wonder that coconut oil is so great to rub into a dandruff plagued scalp as it helps bring the fungus causing this scaly problem under control with no chemical laden shampoos needed.
Coconut oil is also helpful for those with candida overgrowth problems in the gut as it suppresses all manner of gut pathogens. It is the highly beneficial medium chain saturated fat lauric acid found in coconut oil that is responsible for protection from microbial infections of all kinds when coconut oil is consumed in the diet. Lauric acid is also produced by the human mammary gland and what is credited with protecting breastfed infants from viral, bacterial, or protozoal infections.
It is only recently, however, that the conventional medical community has finally begun to appreciate the powerful antimicrobial effect of coconut oil.
Irish researchers have reported from the Athlone Institute of Technology that coconut oil was the only oil of 3 tested (olive oil and vegetable oil being the other two) that was able to prevent Streptococcus mutans, an acid-producing bacterium that is a common inhabitant of the mouth and a major cause of tooth decay, from binding to and damaging tooth enamel.
This finding lends serious credence to the ancient Ayurvedic practice of swishing the mouth with a tablespoon of oil first thing in the morning (oil pulling) which some people report works best using coconut oil.
The coconut oil used in the study was first treated with enzymes simulating the human digestive process in order to more realistically gauge its impact in the body.
The scientists also reported the coconut oil extremely effective at attacking thrush, a yeast (fungal) infection of the mouth which is not surprising given coconut oil's helpfulness with other skin issues like dandruff.
Lead researcher Dr. Damien Brady stated that coconut oil could prove to be an attractive alternative to chemicals in maintaining oral health. Mouthwashes, toothpastes, and other oral products are loaded with chemical additives that can frequently irritate the sensitive tissues of the mouth.
Dr. Brady noted that not only does coconut oil work at relatively low concentrations, but with the worrisome problem of increasing antibiotic resistance, it is important to consider coconut oil a potentially novel new way to control microbial infections.
Dr. Brady and his team now plan to examine how coconut oil and Strep bacteria interface at the molecular level to determine if there are any other strains of bacteria that are inhibited in a similar fashion. They also plan to study antibacterial activity in the gut presumably using coconut oil and how cells lining the digestive tract can become colonized by pathogens.
Free Oral Health Summit Coming Soon!
If the holistic use of coconut oil to improve oral health and possibly prevent tooth decay intrigues you, be sure to register for the free, worldwide online Oral Health Summit that will occur November 11-18, 2012. The Summit features a panel of 20 medical doctors, dentists, nutritionists, and other experts in the field of oral health from 6 different countries who will discuss safe dental alternatives, nontoxic options, foods to prevent and heal existing decay, and safe solutions for mercury fillings, crowns, and root canals.


Join Janette Stuart, WU Expert Presenter and "Angel Whisperer" as we dive deeper into joy and focus on how creativity and passion become our gateways to enhanced joy in our lives. This class is a follow up for the Joy Master Class held on May 10. We'll discuss the sacral chakra as our energy center of creativity and passion in this fun and joyful class which is suitable for all as we are all creative and passionate beings.


The CoulTCell is a coulometric titration setup for measurements of oxygen nonstoichiometric properties of materials at high temperatures, and in different partial pressure of oxygen. The output of these experiments can be used for the investigation of the redox behavior of nonstoichiometric materials.
The system consist of two parts; the cell and the instruments package, to be aquired together or separately. The cell is brass and alumina made, two 8% mol partially stabilized YSZ electrolytes, S-type thermocouple, Swagelok valves and bulkheads and 8mm water cooling- in and outlets. Accessing sample is easy by detaching the outer tube by unscrewing 4 short bolts. Equipped with several spare crucibles. The design is improved version of equipment resulting from years of research development and experience by research fellows Dr. Egil Bakken and Mehdi Pishahang under supervision of professors Svein Stølen and Truls Norby at the University of Oslo.
The instruments package consist of precission power source and a multimeter, controlled by a computer software. The instruments are enclosed in a compact casing, connecting to the computer wuth USB cable and to the cell with BNC cables (cables included).
The system offers a cost-effective alternative to developing and building your own cell for studies, characterization and testing of inorganic materials for purposes like fuel cell components, membrane materials, chemical-looping oxygen carriers, etc. All units are tested and validated with strict requirements.
Real time on screen plots: Pump current, Sensor voltage, Furnace temperature, Pump voltage.
5mm inner diameter Silicon hose with reliable water supply. Recirculating system with a pump and overflow system recommended. Included in the quote only by request.
Vertical tube furnace with tube diameter about 40mm, length of 500mm to 700mm. Suitable furnace included in the quote only by request.
Windows operating system, 1 free usb port.
The setup includes both multichannel voltmeter and precision sourcemeter integrated into a nice instrument casing.
BNC cables connect the instrument to the cell and USB cable instrument to computer.
The software will run on any computer with USB port and Windows operating system.
On this picture: Cell flush out valve, water cooling loop, O-ring seal, 4 threaded screw slots.


text:
import numpy as np
from copy import deepcopy

from ..surface import (fast_cross_3d, _find_nearest_tri_pt, _get_tri_supp_geom,
                       _triangle_coords)
from ..io.constants import FIFF
from ..transforms import apply_trans
from ..utils import logger
from ..parallel import parallel_func
from ..io.compensator import get_current_comp, make_compensator
from ..io.pick import pick_types

##############################################################################
# COIL SPECIFICATION

def _dup_coil_set(coils, coord_frame, t):
    """Make a duplicate"""
    if t is not None and coord_frame != t['from']:
        raise RuntimeError('transformation frame does not match the coil set')
    coils = deepcopy(coils)
    if t is not None:
        coord_frame = t['to']
        for coil in coils:
            coil['r0'] = apply_trans(t['trans'], coil['r0'])
            coil['ex'] = apply_trans(t['trans'], coil['ex'], False)
            coil['ey'] = apply_trans(t['trans'], coil['ey'], False)
            coil['ez'] = apply_trans(t['trans'], coil['ez'], False)
            coil['rmag'] = apply_trans(t['trans'], coil['rmag'])
            coil['cosmag'] = apply_trans(t['trans'], coil['cosmag'], False)
            coil['coord_frame'] = t['to']
    return coils, coord_frame

def _check_coil_frame(coils, coord_frame, bem):
    """Check to make sure the coils are in the correct coordinate frame"""
    if coord_frame != FIFF.FIFFV_COORD_MRI:
        if coord_frame == FIFF.FIFFV_COORD_HEAD:
            # Make a transformed duplicate
            coils, coord_Frame = _dup_coil_set(coils, coord_frame,
                                               bem['head_mri_t'])
        else:
            raise RuntimeError('Bad coil coordinate frame %d' % coord_frame)
    return coils, coord_frame

def _bem_lin_field_coeffs_simple(dest, normal, tri_rr, tri_nn, tri_area):
    """Simple version..."""
    out = np.zeros((3, len(dest)))
    for rr, o in zip(tri_rr, out):
        diff = dest - rr
        dl = np.sum(diff * diff, axis=1)
        x = fast_cross_3d(diff, tri_nn[np.newaxis, :])
        o[:] = tri_area * np.sum(x * normal, axis=1) / (3.0 * dl * np.sqrt(dl))
    return out

def _lin_field_coeff(s, mult, rmags, cosmags, ws, counts, func, n_jobs):
    """Use the linear field approximation to get field coefficients"""
    parallel, p_fun, _ = parallel_func(_do_lin_field_coeff, n_jobs)
    nas = np.array_split
    coeffs = parallel(p_fun(s['rr'], t, tn, ta,
                            rmags, cosmags, ws, counts, func)
                      for t, tn, ta in zip(nas(s['tris'], n_jobs),
                                           nas(s['tri_nn'], n_jobs),
                                           nas(s['tri_area'], n_jobs)))
    return mult * np.sum(coeffs, axis=0)

def _do_lin_field_coeff(rr, t, tn, ta, rmags, cosmags, ws, counts, func):
    """Actually get field coefficients (parallel-friendly)"""
    coeff = np.zeros((len(counts), len(rr)))
    bins = np.repeat(np.arange(len(counts)), counts)
    for tri, tri_nn, tri_area in zip(t, tn, ta):
        # Accumulate the coefficients for each triangle node
        # and add to the corresponding coefficient matrix
        tri_rr = rr[tri]

        # The following is equivalent to:
        #for j, coil in enumerate(coils['coils']):
        #    x = func(coil['rmag'], coil['cosmag'],
        #             tri_rr, tri_nn, tri_area)
        #    res = np.sum(coil['w'][np.newaxis, :] * x, axis=1)
        #    coeff[j][tri + off] += mult * res

        xx = func(rmags, cosmags, tri_rr, tri_nn, tri_area)
        # only loops 3x (one per direction)
        zz = np.array([np.bincount(bins, weights=x * ws,
                                   minlength=len(counts)) for x in xx])
        coeff[:, tri] += zz.T
    return coeff

def _bem_specify_coils(bem, coils, coord_frame, n_jobs):
    """Set up for computing the solution at a set of coils"""
    # Compute the weighting factors to obtain the magnetic field
    # in the linear potential approximation
    coils, coord_frame = _check_coil_frame(coils, coord_frame, bem)

    # leaving this in in case we want to easily add in the future
    #if method != 'simple':  # in ['ferguson', 'urankar']:
    #    raise NotImplementedError
    #else:
    func = _bem_lin_field_coeffs_simple

    # Process each of the surfaces
    rmags = np.concatenate([coil['rmag'] for coil in coils])
    cosmags = np.concatenate([coil['cosmag'] for coil in coils])
    counts = np.array([len(coil['rmag']) for coil in coils])
    ws = np.concatenate([coil['w'] for coil in coils])

    lens = np.cumsum(np.r_[0, [len(s['rr']) for s in bem['surfs']]])
    coeff = np.empty((len(counts), lens[-1]))
    for o1, o2, surf, mult in zip(lens[:-1], lens[1:],
                                  bem['surfs'], bem['field_mult']):
        coeff[:, o1:o2] = _lin_field_coeff(surf, mult, rmags, cosmags,
                                           ws, counts, func, n_jobs)
    # put through the bem
    sol = np.dot(coeff, bem['solution'])
    return sol

def _bem_specify_els(bem, els):
    """Set up for computing the solution at a set of electrodes"""
    sol = np.zeros((len(els), bem['solution'].shape[1]))
    # Go through all coils
    scalp = bem['surfs'][0]
    scalp['geom'] = _get_tri_supp_geom(scalp['tris'], scalp['rr'])
    inds = np.arange(len(scalp['tris']))

    # In principle this could be parallelized, but pickling overhead is huge
    # (makes it slower than non-parallel)
    for k, el in enumerate(els):
        # Go through all 'integration points'
        el_r = apply_trans(bem['head_mri_t']['trans'], el['rmag'])
        for elw, r in zip(el['w'], el_r):
            best = _find_nearest_tri_pt(inds, r, scalp['geom'], True)[2]
            # Calculate a linear interpolation between the vertex values
            tri = scalp['tris'][best]
            x, y, z = _triangle_coords(r, scalp['geom'], best)
            w = elw * np.array([(1.0 - x - y), x, y])
            amt = np.dot(w, bem['solution'][tri])
            sol[k] += amt
    return sol

#############################################################################
# FORWARD COMPUTATION

def _make_ctf_comp_coils(info, coils):
    """Get the correct compensator for CTF coils"""
    # adapted from mne_make_ctf_comp() from mne_ctf_comp.c
    logger.info('Setting up compensation data...')
    comp_num = get_current_comp(info)
    if comp_num is None or comp_num == 0:
        logger.info('    No compensation set. Nothing more to do.')
        return None

    # Need to meaningfully populate comp['set'] dict a.k.a. compset
    n_comp_ch = sum([c['kind'] == FIFF.FIFFV_MEG_CH for c in info['chs']])
    logger.info('    %d out of %d channels have the compensation set.'
                % (n_comp_ch, len(coils)))

    # Find the desired compensation data matrix
    compensator = make_compensator(info, 0, comp_num, True)
    logger.info('    Desired compensation data (%s) found.' % comp_num)
    logger.info('    All compensation channels found.')
    logger.info('    Preselector created.')
    logger.info('    Compensation data matrix created.')
    logger.info('    Postselector created.')
    return compensator

#def _bem_inf_pot(rd, Q, rp):
#    """The infinite medium potential in one direction"""
#    # NOTE: the (4.0 * np.pi) that was in the denominator has been moved!
#    diff = rp - rd
#    diff2 = np.sum(diff * diff, axis=1)
#    return np.sum(Q * diff, axis=1) / (diff2 * np.sqrt(diff2))

def _bem_inf_pots(rr, surf_rr, Q=None):
    """The infinite medium potential in all 3 directions"""
    # NOTE: the (4.0 * np.pi) that was in the denominator has been moved!
    diff = surf_rr.T[np.newaxis, :, :] - rr[:, :, np.newaxis]  # n_rr, 3, n_bem
    diff_norm = np.sum(diff * diff, axis=1)
    diff_norm *= np.sqrt(diff_norm)
    diff_norm[diff_norm == 0] = 1  # avoid nans
    if Q is None:  # save time when Q=np.eye(3) (e.g., MEG sensors)
        return diff / diff_norm[:, np.newaxis, :]
    else:  # get components in each direction (e.g., EEG sensors)
        return np.einsum('ijk,mj->imk', diff, Q) / diff_norm[:, np.newaxis, :]

# This function has been refactored to process all points simultaneously
#def _bem_inf_field(rd, Q, rp, d):
#    """Infinite-medium magnetic field"""
#    diff = rp - rd
#    diff2 = np.sum(diff * diff, axis=1)
#    x = fast_cross_3d(Q[np.newaxis, :], diff)
#    return np.sum(x * d, axis=1) / (diff2 * np.sqrt(diff2))

def _bem_inf_fields(rr, rp, c):
    """Infinite-medium magnetic field in all 3 basis directions"""
    # Knowing that we're doing all directions, the above can be refactored:
    diff = rp.T[np.newaxis, :, :] - rr[:, :, np.newaxis]
    diff_norm = np.sum(diff * diff, axis=1)
    diff_norm *= np.sqrt(diff_norm)
    diff_norm[diff_norm == 0] = 1  # avoid nans
    # This is the result of cross-prod calcs with basis vectors,
    # as if we had taken (Q=np.eye(3)), then multiplied by the cosmags (c)
    # factor, and then summed across directions
    x = np.array([diff[:, 1] * c[:, 2] - diff[:, 2] * c[:, 1],
                  diff[:, 2] * c[:, 0] - diff[:, 0] * c[:, 2],
                  diff[:, 0] * c[:, 1] - diff[:, 1] * c[:, 0]])
    return np.rollaxis(x / diff_norm, 1)

def _bem_pot_or_field(rr, mri_rr, mri_Q, mults, coils, solution, srr,
                      n_jobs, coil_type):
    """Calculate the magnetic field or electric potential

    The code is very similar between EEG and MEG potentials, so we'll
    combine them.
    """
    # multiply solution by "mults" here for simplicity
    # we can do this one in-place because it's not used elsewhere
    solution *= mults

    # Both MEG and EEG have the inifinite-medium potentials
    # This could be just vectorized, but eats too much memory, so instead we
    # reduce memory by chunking within _do_inf_pots and parallelize, too:
    parallel, p_fun, _ = parallel_func(_do_inf_pots, n_jobs)
    nas = np.array_split
    B = np.sum(parallel(p_fun(mri_rr, sr.copy(), mri_Q, sol.copy())
                        for sr, sol in zip(nas(srr, n_jobs),
                                           nas(solution.T, n_jobs))), axis=0)
    # The copy()s above should make it so the whole objects don't need to be
    # pickled...

    # Only MEG gets the primary current distribution
    if coil_type == 'meg':
        # Primary current contribution (can be calc. in coil/dipole coords)
        parallel, p_fun, _ = parallel_func(_do_prim_curr, n_jobs)
        pcc = np.concatenate(parallel(p_fun(rr, c)
                                      for c in nas(coils, n_jobs)), axis=1)
        B += pcc
        B *= 1e-7  # MAG_FACTOR from C code
    return B

def _do_prim_curr(rr, coils):
    """Calculate primary currents in a set of coils"""
    out = np.empty((len(rr) * 3, len(coils)))
    for ci, c in enumerate(coils):
        out[:, ci] = np.sum(c['w'] * _bem_inf_fields(rr, c['rmag'],
                                                     c['cosmag']), 2).ravel()
    return out

def _do_inf_pots(rr, srr, mri_Q, sol):
    """Calculate infinite potentials using chunks"""
    # The following code is equivalent to this, but saves memory
    #v0s = _bem_inf_pots(rr, srr, mri_Q)  # n_rr x 3 x n_surf_rr
    #v0s.shape = (len(rr) * 3, v0s.shape[2])
    #B = np.dot(v0s, sol)

    # We chunk the source rr's in order to save memory
    bounds = np.r_[np.arange(0, len(rr), 1000), len(rr)]
    B = np.empty((len(rr) * 3, sol.shape[1]))
    for bi in range(len(bounds) - 1):
        v0s = _bem_inf_pots(rr[bounds[bi]:bounds[bi + 1]], srr, mri_Q)
        v0s.shape = (v0s.shape[0] * 3, v0s.shape[2])
        B[3 * bounds[bi]:3 * bounds[bi + 1]] = np.dot(v0s, sol)
    return B

def _compute_forwards(src, bem, coils_list, cfs, ccoils_list, ccfs,
                      infos, coil_types, n_jobs):
    """Compute the MEG and EEG forward solutions"""
    if bem['bem_method'] != 'linear collocation':
        raise RuntimeError('only linear collocation supported')

    # Precompute some things that are used for both MEG and EEG
    rr = np.concatenate([s['rr'][s['vertno']] for s in src])
    mults = np.repeat(bem['source_mult'] / (4.0 * np.pi),
                      [len(s['rr']) for s in bem['surfs']])[np.newaxis, :]
    # The dipole location and orientation must be transformed
    mri_rr = apply_trans(bem['head_mri_t']['trans'], rr)
    mri_Q = apply_trans(bem['head_mri_t']['trans'], np.eye(3), False)
    srr = np.concatenate([s['rr'] for s in bem['surfs']])

    # Now, actually compute MEG and EEG solutions
    Bs = list()
    for coil_type, coils, cf, ccoils, ccf, info in zip(coil_types, coils_list,
                                                       cfs, ccoils_list, ccfs,
                                                       infos):
        if coils is None:  # nothing to do
            Bs.append(None)
        else:
            if coil_type == 'meg':
                # Compose a compensation data set if necessary
                compensator = _make_ctf_comp_coils(info, coils)

                # Field computation matrices...
                logger.info('')
                start = 'Composing the field computation matrix'
                logger.info(start + '...')
                solution = _bem_specify_coils(bem, coils, cf, n_jobs)
                if compensator is not None:
                    logger.info(start + ' (compensation coils)...')
                    csolution = _bem_specify_coils(bem, ccoils, ccf, n_jobs)

            elif coil_type == 'eeg':
                solution = _bem_specify_els(bem, coils)
                compensator = None

            # Do the actual calculation
            logger.info('Computing %s at %d source locations '
                        '(free orientations)...'
                        % (coil_type.upper(), len(rr)))
            # Note: this function modifies "solution" in-place
            B = _bem_pot_or_field(rr, mri_rr, mri_Q, mults, coils,
                                  solution, srr, n_jobs, coil_type)

            # Compensate if needed (only done for MEG systems w/compensation)
            if compensator is not None:
                # Compute the field in the compensation coils
                work = _bem_pot_or_field(rr, mri_rr, mri_Q, mults,
                                         ccoils, csolution, srr, n_jobs,
                                         coil_type)
                # Combine solutions so we can do the compensation
                both = np.zeros((work.shape[0], B.shape[1] + work.shape[1]))
                picks = pick_types(info, meg=True, ref_meg=False)
                both[:, picks] = B
                picks = pick_types(info, meg=False, ref_meg=True)
                both[:, picks] = work
                B = np.dot(both, compensator.T)
            Bs.append(B)

    return Bs


Monomyths and Cute Overload in Adventure Time's "Little Brother"
There's a new 5-minute promo out for the live-action Rurouni Kenshin sequels Rurouni Kenshin: Kyoto Inferno and Rurouni Kenshin: The Legend Ends. The footage shows everyone's favorite backwards-swordsman in all three of his moods: business-meeting Battousai, lady-killing Battousai, and everyone's personal favorite: army-slaying Battousai.
Teaser images were released as far back as March of this year, along with a 30 second trailer, neither of which told you much, aside from the fact that the producers might be a tad too faithful to the character designs of the anime/manga. I mean, The Dark Knight's Bane no longer looked like a juggalo, Shishio Makoto doesn't haaaaave to look like Darkman, but what the film lacks in imagination, it makes up for with musket-on-katana-on-ships-sometimes action.
The films will follow the Kyoto Arc of the manga, commonly referred to as the 'proper' finish to the series. Kyoto Inferno and The Legend Ends will see respective Japanese releases on August 1st and barely a month later on September 13th. Check it out below, along with the movie poster.


The Gospel presents a sad story. Our Lord returns to his native place. He teaches in the synagogue, only to receive a rather chilly reception from his own kinsmen. In fact, they "take offense at him."
The passage indicates that the people were familiar with Jesus' doings: "Where did this man get all this? What kind of wisdom has been given him? What might deeds are wrought by his hands? This much astonishes them.
Harder to swallow is the fact that the man doing these things is one of them. "Is he not the carpenter, the son of Mary?" The people know this man, and that familiarity seems to breed contempt. It seems difficult for them to grasp that Jesus could be some kind of great prophet sent by God, much less the divine Son of God. In the end, Jesus could do few mighty deeds there because of their lack of faith.
Perhaps we are not always so different from those people in the synagogue. There are still those who find it hard to accept that a carpenter from Nazareth could possible be the son of God and Savior of the world. We live in a world of advanced science, which is often offended by the idea of the miraculous. Attempts are made to explain away the miracles of Jesus. In the end, faith suffers.
For example, the feeding of the 5,000 had nothing to do with Jesus multiplying loaves and fish. It had more to do with people being inspired by his teaching sharing what they had with one another. Or how about walking on water? Jesus did not really do that. The lake was actually frozen, as a contemporary theory happens to go.
Perhaps these explanations may seem to help make Jesus more familiar and acceptable to us. We can now see Jesus as one of us. He is a great teacher and a good man, but he is simply one of us.
But, if Jesus did not do those great deeds that the Gospels record, then he is not our Redeemer and Savior either. Our redemption was the work of one who was both true God and true man. Atonement for our sins could only be made by one who was true God and true man. The Da Vinci Code was written to convince us that Jesus was nothing more than a mere man. Every miracle recorded in the Gospels is meant to help us believe that Jesus Christ is truly the Son of God. So much effort is expended on keeping God out of the public arena, out of the hearts and minds of men. We can not erase the fact that, in the Incarnation, God entered the public arena for our salvation.
This is what the apostles preached and the evangelists recorded. This is what the Church proclaims.
In the words of C. S. Lewis, "A man who was merely a man and said the sort of things Jesus said would not be a great moral teacher. He would either be a lunatic - on a level with a man who says he is a poached egg - or else he would be the Devil of hell. You must make your choice. Either this man was, and is, the son of God; or else a madman or something worse. You can shut him up for a fool, you can spit at him and kill him as a demon; or you can fall at his feet and call him Lord and God. But let us not come away with any patronizing nonsense about his being a great human teacher. He has not left that open to us. He did not intend to."


text:
Jus' a couple o' white boys lost in the blues: Lovett and Hiatt at UNC
October 29, 2013 By THE FIVE POINTS STAR in Music reviews Tags: Carolina Performing Arts, Jesse Winchester, John Hiatt, Lyle Lovett	Leave a comment
As much as I am disinclined to choose only one kind of music in actual life, I do enjoy playing the game of "if you could have only one, which would it be?" I was thinking about that Sunday night, Oct. 27, while snuggled into the happy crowd at UNC's Memorial Auditorium for an acoustic evening with singer-songwriters Lyle Lovett and John Hiatt and their gleaming guitars, presented by Carolina Performing Arts as part of this season's refreshing Americana series. I heard a little voice in the back of my mind saying, OK, I can give up all those pretty Schubert lieder, and maybe Verdi, too, but I got to have a singing man with a blues guitar when I'm stuck on that desert island.
Between them, Lovett and Hiatt have written a large number of the more intelligent, wry and sensitive rocking country blues songs of the past 35 years, and they took turns playing a choice selection of their own songs, with a few by other writers to leaven the mix. About a quarter of the way into the nearly 3 hour unbroken concert, Lyle Lovett began to tell about learning a certain Michael Franks song from the great Piedmont bluesmen, Sonny Terry and Brownie McGhee, in 1978. Lovett and Hiatt then launched together into that classic, "White Boy Lost in the Blues," Hiatt modulating off Lovett's killer blues riff, and I was transported. Not in place, but in time, back to the spring of 1974 when I heard Sonny and Brownie playing that song on that very stage. It is a little different when the white boys are playing it, but I think the old black bluesmen would have been satisfied with Hiatt's growl and Lovett's pick-and-frail style. Being white, they don't have to gentle down the mockery; they blistered that thing.
John Hiatt. Photo courtesy of the artist/CPA.
"You bought you a six string Gibson
You bought you a great big house
You try to sing like Muddy Waters
And play like Lightnin' sounds
But since I blowed my harp
You feelin' mean and confused.
It got you chained to your earphones
You just a white boy lost in the blues."
Lovett recorded this song on his latest album, Release Me.
Not only was this a concert of great songs by two fantastic guitarists, it was an evening of conversation between them. I'm sure they had it pretty well mapped out, but both men have more-than-sufficient stage skills, so the between-song chat came across as fresh and intimate, and was informative as often as it was amusing. And I can't think when I've ever been to an auditorium show that felt as comfortable as a house party. Certainly I've never heard a high-dollar musician talk onstage–not in song–about dropping out of school or stealing cars. The pair talked about their own music, each other's music and technique, and swapped stories about other musicians and bands. Lovett told about the first time he saw Hiatt–he was playing guitar behind Ry Cooder. Said Lovett: "I thought he was…brave." Yup, and just damn fine.
Talk is great, but there was a gracious plenty of musical action,too, with both men singing several of their best-known songs: "When I was a Very Young Man," "Life's Been Good to Me," "Don't Touch My Hat," by Lovett; "This Thing Called Love" ("I ain't no porcupine/take off your kid gloves"), "Crossing Muddy Water," "Drive South," by Hiatt, and many more. Lyle's been to Chapel Hill more than once, and he dedicated one song to the current Julians running Julian's clothing store, and another to "anyone who might have been there at The Cave in 1986." In a particularly graceful gesture, the pair chose as their set-closer a beautiful old tune by the under-appreciated Jesse Winchester, "Brand-New Tennessee Waltz." How could it get better? Well, they came back for an encore. Hiatt crooned "When the Road Gets Dark/Have a Little Faith in Me," soaring up into a sustained falsetto that drew out the tears, before Lyle kicked us on out of there with a rousing rendition of "My Baby Don't Tolerate."
Lyle Lovett. Photo courtesy of the artist/CPA.
« Variations on the Piano
Mad Mandolin Genius: Chris Thile Solo at UNC »